Strange behaviour, program segfaults

Peter Johnson peter at tortall.net
Mon Apr 10 21:12:39 PDT 2006


On Mon, 10 Apr 2006, André Reffhaug wrote:

> On 4/10/06, Michael Urman <mu at tortall.net> wrote:
>> Just as a data point, since I don't know gas the way Peter does. I get
>> the following errors when I run it with your code:
>>
>> % ./yasm -p gas -f elf gastest.asm
>> % ld gastest.o -o gastest
>> ld: gastest: warning: allocated section `.text' not in segment
>> % ./gastest
>> zsh: exec format error: ./gastest
>>
>> When I crossreferenced for the usage in our test cases, it uses ".text"
>> instead of ".section .text" so I tried that and it seems to execute
>> properly:
>>
>> % ./gastest
>> zsh: exit 33    ./gastest
>>
>> Peter will have to sort out whether this behavior is by design or by
>> accident. Since you say it works with as, I'm going to guess it's a
>> design oversight. And a great thing to catch before the final release of
>> 0.5.0! :)
>
> This is quite interesting. First off, my ld doesn't give me the
> warning you get for the .section .text-line at all. It just links in
> silence. (ld version 2.16.1).
>
> And second, when removing ".section" from the sourcecode, the compiled
> version still segfaults on my system. Yasm is latest release, rc2.
>
> Very strange, and perhaps import as to a new release.

I'll take a look at changing the .section behavior (why it doesn't work is 
that no section flags have been specified; yasm defaults to a very 
restrictive non-code set of flags, whereas GAS either guesses based on 
section name or defaults to code).

I see the same behavior Michael sees, however: if ".section .text" is 
replaced with ".text", the code in your original message runs just fine 
after being assembled with yasm and linked.  Is that the entire test 
you're running or is there some additional code that's also in your local 
version?  Linking with any other code?

Thanks,
Peter


More information about the yasm-devel mailing list