This is the mail archive of the
mailing list for the binutils project.
Re: ld: Section corrupted with elf64-x86-64 input -> elf32-i386 output
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Antoine Kaufmann <toni at famkaufmann dot info>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sun, 27 Sep 2015 06:27:24 -0700
- Subject: Re: ld: Section corrupted with elf64-x86-64 input -> elf32-i386 output
- Authentication-results: sourceware.org; auth=none
- References: <20150927113418 dot GL17306 at deathstar dot cs dot washington dot edu>
On Sun, Sep 27, 2015 at 4:34 AM, Antoine Kaufmann <email@example.com> wrote:
> I ran into some weird behavior, most likely a bug, in in admittedly even
> weirder setting... So I figured I'd check here if I'm missing something and
> that's somehow the expected behavior, before I'd file a bug.
> Basically I'm linking elf64-x86-64 files together and outputting a elf32-i386
> executable (long story, involving a mix of 32 bit and 64 bit code running bare
> metal). Now I noticed that some of my string constants were getting corrupted
> during linking, truncated mostly. I've tried to reduce this to a minimal
> example to show what happens (tested with debian's 2.25.1 and a recent git
>> $ cat a.s
>> .section .rodata.str1.1,"aMS",@progbits,1
>> .byte 0x0, 0x0, 0x2, 0x3, 0x0
>> .string "ABCD"
>> $ as -o a.o a.s
>> $ ld --oformat elf32-i386 -o b a.o
>> ld: warning: cannot find entry symbol _start; defaulting to 0000000000400054
>> $ objdump -s -j .rodata.str1.1 a.o
>> a.o: file format elf64-x86-64
>> Contents of section .rodata.str1.1:
>> 0000 00000203 00414243 4400 .....ABCD.
>> + objdump -s -j .rodata b
>> b: file format elf32-i386
>> Contents of section .rodata:
>> 400054 00000203 00414243 .....ABC
> Is there something I'm missing or is this a bug? If the latter, any suggestions
> on where I should start looking into the code?
Please open a binutils bug report with a testcase. I will investigate it.