From: Michal M. <ak...@ja...> - 2012-08-10 12:31:51
Attachments:
patch
|
Hello, I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. Elftoolchain compiles after applying the attached patch, but strip seems to have a bug. Here is the difference between a binary stripped with gnu strip, and elftoolchain strip: $ diff dump.elf dump.gnu 73,77c73,77 < p_offset: 120128 < p_vaddr: 0x81d540 < p_paddr: 0x81d540 < p_filesz: 0 < p_memsz: 0 --- > p_offset: 119216 > p_vaddr: 0x71d1b0 > p_paddr: 0x71d1b0 > p_filesz: 912 > p_memsz: 912 83,87c83,87 < p_offset: 119216 < p_vaddr: 0x71d1b0 < p_paddr: 0x71d1b0 < p_filesz: 912 < p_memsz: 10504 --- > p_offset: 120128 > p_vaddr: 0x81d540 > p_paddr: 0x81d540 > p_filesz: 0 > p_memsz: 9592 - two sections are swapped, and their p_memsz are wrong. This results in a segfault. After stripping the binary a second time there is another difference: $ diff dump.elf dump.elfelf 74,75c74,75 < p_vaddr: 0x81d540 < p_paddr: 0x81d540 --- > p_vaddr: 0x71d540 > p_paddr: 0x71d540 - running this binary results in an Abort trap. The same applies to OpenBSD. -- Michal Mazurek |
From: Kai W. <kai...@gm...> - 2012-08-10 22:19:06
|
Hi, On Fri, Aug 10, 2012 at 02:16:28PM +0200, Michal Mazurek wrote: > Hello, > > I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. > > > Elftoolchain compiles after applying the attached patch, but strip seems > to have a bug. Here is the difference between a binary stripped with gnu > strip, and elftoolchain strip: Thanks for reporting this bug. Could you please put the binary file you used to test strip somewhere online, or email it to me? Thanks, Kai |
From: Michal M. <ak...@ja...> - 2012-08-11 06:53:32
|
On Sat, Aug 11, 2012 at 12:18:55AM +0200, Kai Wang wrote: > Hi, > > On Fri, Aug 10, 2012 at 02:16:28PM +0200, Michal Mazurek wrote: > > Hello, > > > > I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. > > > > > > Elftoolchain compiles after applying the attached patch, but strip seems > > to have a bug. Here is the difference between a binary stripped with gnu > > strip, and elftoolchain strip: > > Thanks for reporting this bug. Could you please put the binary file > you used to test strip somewhere online, or email it to me? I uploaded the binary files here (the make program): http://akfaew.jasminek.net/crap/elftoolchain/ make.notstripped - not stripped make.elf - stripped with elftoolchain make.gnu - stripped with gnu strip -- Michal Mazurek |
From: Kai W. <kai...@gm...> - 2012-08-11 15:17:38
|
On Sat, Aug 11, 2012 at 08:53:19AM +0200, Michal Mazurek wrote: > On Sat, Aug 11, 2012 at 12:18:55AM +0200, Kai Wang wrote: > > Hi, > > > > On Fri, Aug 10, 2012 at 02:16:28PM +0200, Michal Mazurek wrote: > > > Hello, > > > > > > I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. > > > > > > > > > Elftoolchain compiles after applying the attached patch, but strip seems > > > to have a bug. Here is the difference between a binary stripped with gnu > > > strip, and elftoolchain strip: > > > > Thanks for reporting this bug. Could you please put the binary file > > you used to test strip somewhere online, or email it to me? > > I uploaded the binary files here (the make program): > http://akfaew.jasminek.net/crap/elftoolchain/ > > make.notstripped - not stripped > make.elf - stripped with elftoolchain > make.gnu - stripped with gnu strip Thanks. It should be fixed by r2540. Let me know if it still doesn't work for you. Kai |
From: Michal M. <ak...@ja...> - 2012-08-11 16:43:01
|
On Sat, Aug 11, 2012 at 05:17:27PM +0200, Kai Wang wrote: > On Sat, Aug 11, 2012 at 08:53:19AM +0200, Michal Mazurek wrote: > > On Sat, Aug 11, 2012 at 12:18:55AM +0200, Kai Wang wrote: > > > Hi, > > > > > > On Fri, Aug 10, 2012 at 02:16:28PM +0200, Michal Mazurek wrote: > > > > Hello, > > > > > > > > I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. > > > > > > > > > > > > Elftoolchain compiles after applying the attached patch, but strip seems > > > > to have a bug. Here is the difference between a binary stripped with gnu > > > > strip, and elftoolchain strip: > > > > > > Thanks for reporting this bug. Could you please put the binary file > > > you used to test strip somewhere online, or email it to me? > > > > I uploaded the binary files here (the make program): > > http://akfaew.jasminek.net/crap/elftoolchain/ > > > > make.notstripped - not stripped > > make.elf - stripped with elftoolchain > > make.gnu - stripped with gnu strip > > Thanks. It should be fixed by r2540. Let me know if it still doesn't > work for you. Thank you, I managed to build world now, however there is still a difference. Stripping the uploaded binary make.notstripped with gnu strip and elftoolchain strip produces this difference: --- dump.elf Wed Aug 8 11:28:00 2012 +++ dump.gnu Wed Aug 8 11:27:57 2012 @@ -19,16 +19,16 @@ program header: entry: 0 p_type: PT_PHDR p_offset: 64 p_vaddr: 0x400040 p_paddr: 0x400040 - p_filesz: 672 - p_memsz: 672 + p_filesz: 560 + p_memsz: 560 p_flags: PF_X|PF_R p_align: 8 entry: 1 p_type: PT_INTERP p_offset: 736 p_vaddr: 0x4002e0 >From the output of hexdump it seems this is the only difference, and thus might be a bug: $ diff hex.elf hex.gnu 7c7 < 00000060 a0 02 00 00 00 00 00 00 a0 02 00 00 00 00 00 00 |................| --- > 00000060 30 02 00 00 00 00 00 00 30 02 00 00 00 00 00 00 |0.......0.......| This warning generated by clang might also interest you: ===> readelf clang -O3 -pipe -pipe -I. -I/usr/ports/pobj/bitrig-elftoolchain-2540/elftoolchain-2540/readelf -I../common -I../libdwarf -I../libelf -I../libelftc -I/usr/local/include -nostdinc -idirafter /usr/include -c readelf.c readelf.c:6135:44: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand] if ((re->options & RE_VV) || (re->options && RE_S)) ^ ~~~~ readelf.c:6135:44: note: use '&' for a bitwise operation if ((re->options & RE_VV) || (re->options && RE_S)) ^~ & readelf.c:6135:44: note: remove constant to silence this warning if ((re->options & RE_VV) || (re->options && RE_S)) ~^~~~~~~ 1 warning generated. -- Michal Mazurek |
From: Kai W. <kai...@gm...> - 2012-08-12 16:23:30
|
On Sat, Aug 11, 2012 at 06:42:50PM +0200, Michal Mazurek wrote: > On Sat, Aug 11, 2012 at 05:17:27PM +0200, Kai Wang wrote: > > On Sat, Aug 11, 2012 at 08:53:19AM +0200, Michal Mazurek wrote: > > > On Sat, Aug 11, 2012 at 12:18:55AM +0200, Kai Wang wrote: > > > > Hi, > > > > > > > > On Fri, Aug 10, 2012 at 02:16:28PM +0200, Michal Mazurek wrote: > > > > > Hello, > > > > > > > > > > I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. > > > > > > > > > > > > > > > Elftoolchain compiles after applying the attached patch, but strip seems > > > > > to have a bug. Here is the difference between a binary stripped with gnu > > > > > strip, and elftoolchain strip: > > > > > > > > Thanks for reporting this bug. Could you please put the binary file > > > > you used to test strip somewhere online, or email it to me? > > > > > > I uploaded the binary files here (the make program): > > > http://akfaew.jasminek.net/crap/elftoolchain/ > > > > > > make.notstripped - not stripped > > > make.elf - stripped with elftoolchain > > > make.gnu - stripped with gnu strip > > > > Thanks. It should be fixed by r2540. Let me know if it still doesn't > > work for you. > > Thank you, I managed to build world now, however there is still a difference. > Stripping the uploaded binary make.notstripped with gnu strip and elftoolchain > strip produces this difference: Thanks for the feedback. readelf(1) issue was fixed by r2541. The strip(1) different phdr size issue should be fixed by r2542. Kai |
From: Michal M. <ak...@ja...> - 2012-08-14 18:08:24
|
On Sun, Aug 12, 2012 at 06:23:18PM +0200, Kai Wang wrote: > On Sat, Aug 11, 2012 at 06:42:50PM +0200, Michal Mazurek wrote: > > On Sat, Aug 11, 2012 at 05:17:27PM +0200, Kai Wang wrote: > > > On Sat, Aug 11, 2012 at 08:53:19AM +0200, Michal Mazurek wrote: > > > > On Sat, Aug 11, 2012 at 12:18:55AM +0200, Kai Wang wrote: > > > > > Hi, > > > > > > > > > > On Fri, Aug 10, 2012 at 02:16:28PM +0200, Michal Mazurek wrote: > > > > > > Hello, > > > > > > > > > > > > I'm trying to get elftoolchain to work on Bitrig, an OpenBSD fork. > > > > > > > > > > > > > > > > > > Elftoolchain compiles after applying the attached patch, but strip seems > > > > > > to have a bug. Here is the difference between a binary stripped with gnu > > > > > > strip, and elftoolchain strip: > > > > > > > > > > Thanks for reporting this bug. Could you please put the binary file > > > > > you used to test strip somewhere online, or email it to me? > > > > > > > > I uploaded the binary files here (the make program): > > > > http://akfaew.jasminek.net/crap/elftoolchain/ > > > > > > > > make.notstripped - not stripped > > > > make.elf - stripped with elftoolchain > > > > make.gnu - stripped with gnu strip > > > > > > Thanks. It should be fixed by r2540. Let me know if it still doesn't > > > work for you. > > > > Thank you, I managed to build world now, however there is still a difference. > > Stripping the uploaded binary make.notstripped with gnu strip and elftoolchain > > strip produces this difference: > > Thanks for the feedback. readelf(1) issue was fixed by r2541. The > strip(1) different phdr size issue should be fixed by r2542. Thanks, Bitrig now builds fine. We'd like to replace GNU tools with elftoolchain. Would you mind releasing the fixed version 0.5.2? -- Michal Mazurek |