[Bug 1205362] [NEW] bizarre stripping of osabi field
Andrew Suffield
asuffiel at cisco.com
Fri Jul 26 14:51:05 UTC 2013
Public bug reported:
I'm using binutils-multiarch to strip freebsd binaries. I've minimised
this test case a bit from how I found the problem, to make it clear how
strange this is.
I've got chroots of precise and raring in both i386 and amd64 versions,
all sitting on one box. I've installed binutils-multiarch into all four
of these. Then I copy a freebsd binary into the chroot, and run strip on
it.
asuffiel at asuffiel-u-dsk:~$ for i in /srv/precise-* /srv/raring-*; do echo $i; readelf -h $i/tmp/init; done
/srv/precise-amd64
ELF Header:
Magic: 7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - FreeBSD
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
/srv/precise-i386
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
/srv/raring-amd64
ELF Header:
Magic: 7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - FreeBSD
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
/srv/raring-i386
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
Notice the OS/ABI field (byte 7 of the magic). In the amd64 chroots, it has been correctly left as a 9, which is freebsd. In the i386 chroots, it has been incorrectly reset to zero, which is sysv. Removing this byte breaks binary loading on freebsd - the kernel won't run it.
I have no idea what's going on here. Sample binary attached to make it
easy to reproduce.
** Affects: binutils (Ubuntu)
Importance: Undecided
Status: New
** Attachment added: "Sample freebsd binary"
https://bugs.launchpad.net/bugs/1205362/+attachment/3750021/+files/init
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to binutils in Ubuntu.
https://bugs.launchpad.net/bugs/1205362
Title:
bizarre stripping of osabi field
Status in “binutils” package in Ubuntu:
New
Bug description:
I'm using binutils-multiarch to strip freebsd binaries. I've minimised
this test case a bit from how I found the problem, to make it clear
how strange this is.
I've got chroots of precise and raring in both i386 and amd64
versions, all sitting on one box. I've installed binutils-multiarch
into all four of these. Then I copy a freebsd binary into the chroot,
and run strip on it.
asuffiel at asuffiel-u-dsk:~$ for i in /srv/precise-* /srv/raring-*; do echo $i; readelf -h $i/tmp/init; done
/srv/precise-amd64
ELF Header:
Magic: 7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - FreeBSD
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
/srv/precise-i386
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
/srv/raring-amd64
ELF Header:
Magic: 7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - FreeBSD
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
/srv/raring-i386
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x80480c0
Start of program headers: 52 (bytes into file)
Start of section headers: 535664 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 15
Section header string table index: 14
Notice the OS/ABI field (byte 7 of the magic). In the amd64 chroots, it has been correctly left as a 9, which is freebsd. In the i386 chroots, it has been incorrectly reset to zero, which is sysv. Removing this byte breaks binary loading on freebsd - the kernel won't run it.
I have no idea what's going on here. Sample binary attached to make it
easy to reproduce.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/1205362/+subscriptions
More information about the foundations-bugs
mailing list