[cfe-dev] GNU assembler syntax for strlen

Eli Friedman eli.friedman at gmail.com
Tue Oct 16 13:53:08 PDT 2012


On Tue, Oct 16, 2012 at 1:47 PM, Andrew Pennebaker
<andrew.pennebaker at gmail.com> wrote:
>
>> 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 was just compiling with "clang test.s"; using trunk clang on OS X 10.8.

-Eli



More information about the cfe-dev mailing list