comp.lang.ada
 help / color / mirror / Atom feed
* VxWorks: Link problem
@ 2002-02-01 11:35 Petter Fryklund
  2002-02-01 16:37 ` Ted Dennison
  0 siblings, 1 reply; 2+ messages in thread
From: Petter Fryklund @ 2002-02-01 11:35 UTC (permalink / raw)


I get undefined reference for high123 and low123 when trying to make
VwWorks_rom including this little neat machine code: (AdaMULTI builds OK!)

with Machine_Code;
procedure rdtsc (High, Low : out Interfaces.Unsigned_32) is

   high123 : Interfaces.Unsigned_32;
   low123  : Interfaces.Unsigned_32;
   pragma Export (C, High123, "high123");
   pragma Export (C, Low123, "low123");


   procedure Do_Inline_Code is
      use Machine_Code;
   begin
      asm'(inst => "rdtsc                            ");
      asm'(inst => "movl    %eax,high123             ");
      asm'(inst => "movl    %edx,low123              ");
   end Do_Inline_Code;

begin
   Do_Inline_Code;
   High := High123;
   Low  := Low123;
end Rdtsc;

(This is done in order to get 64 bit tick counter.) Any suggestions.





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

* Re: VxWorks: Link problem
  2002-02-01 11:35 VxWorks: Link problem Petter Fryklund
@ 2002-02-01 16:37 ` Ted Dennison
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Dennison @ 2002-02-01 16:37 UTC (permalink / raw)


"Petter Fryklund" <qsbpefr@esavionics.se> wrote in message news:<a3dt2s$t7j$1@newstoo.ericsson.se>...
> I get undefined reference for high123 and low123 when trying to make
> VwWorks_rom including this little neat machine code: (AdaMULTI builds OK!)
> procedure rdtsc (High, Low : out Interfaces.Unsigned_32) is
> 
>    high123 : Interfaces.Unsigned_32;
>    low123  : Interfaces.Unsigned_32;
>    pragma Export (C, High123, "high123");
>    pragma Export (C, Low123, "low123");

Out of curiosity, why are you exporting these? They appear to be
internal variables. I don't see what good it would be for some other
external routine to link to them. Do you actually have another routine
somewhere that tries to link against them?

I'm not sure this is legal in any event, as the variables are declared
local to a procedure, not in a global conext. They get allocated on
the stack when the routine is entered, and removed from the stack when
it exits. Thus there's no static address for external routines to bind
to. If you really want them exported, they should probably be declared
in the outer scope of a package spec or body.

-- 
T.E.D. 
Home     -  mailto:dennison@telepath.com (Yahoo: Ted_Dennison)
Homepage -  http://www.telepath.com/dennison/Ted/TED.html



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

end of thread, other threads:[~2002-02-01 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-01 11:35 VxWorks: Link problem Petter Fryklund
2002-02-01 16:37 ` Ted Dennison

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