What is the correct way to declare assembler global variable ?

Konstantin Belousov kostikbel at gmail.com
Fri May 3 20:30:24 UTC 2013


On Fri, May 03, 2013 at 01:10:29PM -0700, Yuri wrote:
> I am trying to compile this code fragment into my program (taken from 
> lib/libc/amd64/sys/sbrk.S):
> void my_func() {
>   ...
>    __asm__ __volatile__(
>        "movq .curbrk(%%rip), %%rax;"
>        "lea  .curbrk(%%rip), %%rdx;"
>        "movq %%rax, %0;"
>        "movq %%rdx, %1;"
>        : "=r" (my_curbrk),
>          "=r" (my_curbrk_ptr)
>        :: "%rax", "%rdx");
>    ...
> }
> 
> I get a warning:
> /usr/bin/ld: warning: type and size of dynamic symbol 
> `.curbrk@@FBSDprivate_1.0' are not defined
> 
> What is the correct way to declare .curbrk in in-place assembly?

Formal answer is for you to read about the .type directive in the GNU
as manual. Also, you need to read about either common symbols, or about
the .size directive.

But, note that you cannot access hidden libc symbols from the code which
links to libc (dynamically). You probably need to re-consider higher-level
approach to your issue.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130503/9b7fe086/attachment.sig>


More information about the freebsd-hackers mailing list