[cfe-dev] GNU assembler syntax for strlen

Andrew Pennebaker andrew.pennebaker at gmail.com
Tue Oct 16 13:47:36 PDT 2012


> The following links, runs, and returns an exit code of 15 for me on OSX:
>
> .data
> msg: .asciz "Hello, world!\n"
> .set len, . - msg
>
> .text
> .globl _main
> _main:
>         push $len
>         pop %eax
>         ret
>

Good to know. I copied this snippet to test.s and tried building on my Mac.

$ clang -c -o test.o -arch i386 test.s
$ ld -o test -macosx_version_min 10.6 -arch i386 test.o
Undefined symbols for architecture i386:
  "start", referenced from:
     -u command line option
ld: symbol(s) not found for architecture i386

So I rename _main to start, reassemble, and continue linking.

$ clang -c -o test.o -arch i386 test.s
$ ld -o test -macosx_version_min 10.6 -arch i386 test.o
ld: section __data (address=0x00002000, size=4294967307) would make the
output executable exceed available address range for architecture i386

Eli, what are your build commands? Which versions of the developer tools
are you using?

I finally managed to write a
hello.s<https://github.com/mcandre/mcandre/blob/master/gas/hello/freebsd/hello.s>that
builds and runs without problem, using as. clang refuses to assemble
it.

-- 
Cheers,

Andrew Pennebaker
www.yellosoft.us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121016/25c3e109/attachment.html>


More information about the cfe-dev mailing list