comp.lang.ada
 help / color / mirror / Atom feed
* Pragma import => pointer in mapping table ?
@ 2013-11-05  9:23 wkernow
  0 siblings, 0 replies; 6+ messages in thread
From: wkernow @ 2013-11-05  9:23 UTC (permalink / raw)


Hello,

This is the first time I post in newsgroup.

In my code, I hamon code j'ai un :

pragma import (C, X, "X");

avec tout ce qu'il faut avant (pragma convention, déclaration de X et "X" est tiré d'un fichier C)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* pragma import => pointer in mapping table ?
@ 2013-11-05  9:49 wkernow
  2013-11-05 12:56 ` Simon Wright
  2013-11-08 18:52 ` Per Sandberg
  0 siblings, 2 replies; 6+ messages in thread
From: wkernow @ 2013-11-05  9:49 UTC (permalink / raw)


Hello,

This is the first time I write in a newsgroup.

In my code, I have : 

pragma import (C, X, "varX_C");

with everything that I need before (pragma convention, declaration of varX, "X_C" comes from a C file) 

Code is ok but my problem is about mapping file. Mapping table is a file which identifies each variable by an address. This file come from toolchain (varX 0x01891234)

In deed, I saw that all variables X derived from a "pragma import" are considered as pointers in mapping table whereas variables type of varX are not access types (basic types).

My hypothesis is that pragma import create an access to C data "varX_C" from a exterior point of view of ada code (so by mapping table).

To confirm my hypothesis, 2 questions : 
1) Are you ok ?
2) Is possible to define an option in toolchain in order to define adressing mode (for addresses in mapping file from pragma import) in direct mode (on ADA data) instead of indirect mode (on C data). Or is it a default option ?

if I'm wrong or you don't understand :
3) In genaral, I don't understand how a basic variable (type BOOLEAN) in ADA code can be considered as a pointer to a BOOLEAN in an mapping file derived from toolchain ?

Thank you

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma import => pointer in mapping table ?
  2013-11-05  9:49 pragma " wkernow
@ 2013-11-05 12:56 ` Simon Wright
  2013-11-05 18:27   ` wkernow
  2013-11-08 18:52 ` Per Sandberg
  1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 2013-11-05 12:56 UTC (permalink / raw)


wkernow@gmail.com writes:

> In deed, I saw that all variables X derived from a "pragma import" are
> considered as pointers in mapping table whereas variables type of varX
> are not access types (basic types).

I expect the format of the map file depends on the version of the linker
ld used on your system.

But, what in the mapping table leads you to conclude that these
variables are treated as pointers?

If the C code contains a variable foo and the Ada code uses pragma
Import to access it, then the Ada-derived object module contains an
unsatisfied reference to the symbol foo (possibly _foo) and the
C-derived object module contains a definition of the symbol; the linker
uses the definition to satisfy the reference.

So what we have is a variable at an address which is known, and when the
Ada code reads the variable the corresponding machine code loads the
data at that address into a register (or whatever is appropriate).

You could think of this as an access via a pointer at the machine code
level, but at the Ada level this is just the same as any other variable
access.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma import => pointer in mapping table ?
  2013-11-05 12:56 ` Simon Wright
@ 2013-11-05 18:27   ` wkernow
  2013-11-05 21:12     ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: wkernow @ 2013-11-05 18:27 UTC (permalink / raw)


> But, what in the mapping table leads you to conclude that these
> variables are treated as pointers?

Because, experiences prove it.
In deed, I'm using an external program which reads the map file. This program reads/writes a value of a variable. User can indicate to this program if the variable is a pointer or not.
When user wants to read direct value, answer is an address (0x019dc345).
When user wants to read indirect value (by a poniter), answer is a value (1).
When user wantd to read direct value of 0x019dc345, answer is a value (1).

> You could think of this as an access via a pointer at the machine code
> level, but at the Ada level this is just the same as any other variable
> access.

I understand your argument. 

I can't access to toolchain easily.
Do you think I need to look for the linker ? Or/and see how map file is built ?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma import => pointer in mapping table ?
  2013-11-05 18:27   ` wkernow
@ 2013-11-05 21:12     ` Simon Wright
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Wright @ 2013-11-05 21:12 UTC (permalink / raw)


wkernow@gmail.com writes:

>> But, what in the mapping table leads you to conclude that these
>> variables are treated as pointers?
>
> Because, experiences prove it.
> In deed, I'm using an external program which reads the map file. This
> program reads/writes a value of a variable. User can indicate to this
> program if the variable is a pointer or not.
> When user wants to read direct value, answer is an address (0x019dc345).
> When user wants to read indirect value (by a poniter), answer is a value (1).
> When user wantd to read direct value of 0x019dc345, answer is a value (1).

This sounds to me just like what I said in the previous post.

>> You could think of this as an access via a pointer at the machine code
>> level, but at the Ada level this is just the same as any other variable
>> access.
>
> I understand your argument.
>
> I can't access to toolchain easily.
> Do you think I need to look for the linker ? Or/and see how map file
> is built ?

Pretty sure I haven't used a map file since 1984, so I can't answer
this.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pragma import => pointer in mapping table ?
  2013-11-05  9:49 pragma " wkernow
  2013-11-05 12:56 ` Simon Wright
@ 2013-11-08 18:52 ` Per Sandberg
  1 sibling, 0 replies; 6+ messages in thread
From: Per Sandberg @ 2013-11-08 18:52 UTC (permalink / raw)


You have asked some question about some very low level details in some
implementation, but may i ask what is it you want to achive by reading
.map-files, wont the linker just solve your problem ??
If you got some header files that are reasonably clean what don't just:
	"g++ -fdump-ada-spec"
 and be happy ??
/Per


 On Tue, 5 Nov 2013 01:49:31 -0800 (PST)
wkernow@gmail.com wrote:

> Hello,
> 
> This is the first time I write in a newsgroup.
> 
> In my code, I have : 
> 
> pragma import (C, X, "varX_C");
> 
> with everything that I need before (pragma convention, declaration of
> varX, "X_C" comes from a C file) 
> 
> Code is ok but my problem is about mapping file. Mapping table is a
> file which identifies each variable by an address. This file come
> from toolchain (varX 0x01891234)
> 
> In deed, I saw that all variables X derived from a "pragma import"
> are considered as pointers in mapping table whereas variables type of
> varX are not access types (basic types).
> 
> My hypothesis is that pragma import create an access to C data
> "varX_C" from a exterior point of view of ada code (so by mapping
> table).
> 
> To confirm my hypothesis, 2 questions : 
> 1) Are you ok ?
> 2) Is possible to define an option in toolchain in order to define
> adressing mode (for addresses in mapping file from pragma import) in
> direct mode (on ADA data) instead of indirect mode (on C data). Or is
> it a default option ?
> 
> if I'm wrong or you don't understand :
> 3) In genaral, I don't understand how a basic variable (type BOOLEAN)
> in ADA code can be considered as a pointer to a BOOLEAN in an mapping
> file derived from toolchain ?
> 
> Thank you


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-08 18:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05  9:23 Pragma import => pointer in mapping table ? wkernow
  -- strict thread matches above, loose matches on Subject: below --
2013-11-05  9:49 pragma " wkernow
2013-11-05 12:56 ` Simon Wright
2013-11-05 18:27   ` wkernow
2013-11-05 21:12     ` Simon Wright
2013-11-08 18:52 ` Per Sandberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox