Re: Help on build failure of patchelf on mips variants

James Cowgill <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <[email protected]>
Hi,

On Tue, 2016-04-05 at 16:13 -0300, Felipe Sateler wrote:
> I'm currently at a loss on why does patchelf fail to build (or rather,
> it fails its testsuite) on all mips variants[1].
> 
> Patchelf modifies ELF binaries, to add/remove RPATH and other
> sections. On all mips variants, some tests fail. From what I can tell,
> the loader complains that the new (altered) file has an invalid
> MIPS.abiflags section, and yet from what I can tell both the original
> and altered binaries have the same (as reported by readelf).
> 
> I have printed some more logs at the upstream issue tracker:
> https://github.com/NixOS/patchelf/issues/82
> 
> Any help would be appreciated. I'd rather not remove patchelf from mips.

I had a go at using patchelf on a hello world executable and the
executable immediately segfaulted. From 'readelf -e':

Before:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 3] .MIPS.abiflags    MIPS_ABIFLAGS   00400188 000188 000018 18   A  0   0  8

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  ABIFLAGS       0x000188 0x00400188 0x00400188 0x00018 0x00018 R   0x8

After:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 1] .MIPS.abiflags    MIPS_ABIFLAGS   003fc174 000174 000018 18   A  0   0  4

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  ABIFLAGS       0x004188 0x00400188 0x00400188 0x00018 0x00018 R   0x8

Here the ABIFLAGS segment (this is a special MIPS specific segment
type) is wrong after running patchelf. The offset and virtaddr are not
the same as the values used in the section header. Infact they don't
seem to point to any section at all. This is probably causing the
dynamic linker to read some garbage, causing the segfault.

If I recall, the ABIFLAGS were first read by glibc 2.22 which might be
why it only recently started failing.

James
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAABCgAGBQJXBD07AAoJEMfxZ23qLQHv/oAQAJMo64noehRhvb9qMgcyf1Zc
aJ7erXsZ95L9ve7Dx3hQO7c1BU7RLjuHEL8kHg3ny1+wY21JNUZvZ5mfa/c9EEGy
3oRbhEYmt6IWEbX8SgP2AFZg4cvBM9iVyDRt1iCefIdPoNP3gkmaER1ZV/HF5iS3
YjLc8vSDpXnfFgtgd0lfRX5Kvx+1gv4JZ1v3mZdIwdsN/75/2T86JzFPqA2aEroI
DrftLplPsOOrTroZN5Xbw1641SmBJQk8cMEunFjUtpKheVwbXpjCqFUM5O6aOH0H
4jfgBNAWTUTI3WlmjPhYaufb9d188Lq3pKEBLXPVPEAjs2DnGZw7hYDHJeX/PJWc
fWlnWoVBnVK8j3hQMFj98q4cVdQaSAuGCJhQMbSr1nYArComYl7LcjsTbicBQdp2
yR8eZEY5nlGZUUdhgtS4Za6uPLyDuJE4y8GSxV9ksTedf5piGEwcHyDRSihzKpzo
sRqw69ks5kf6hkH0hUX6QO3DPIBDSium6PwgA3JsXpHQD9SiB1lHTM3bYq9wOOA6
HjRbfq88tuq1Ql7F6NfBysbxr1/l9MJeQYQLw/Y9OsoUmTW+iLU82plbtUr2SAQ0
msTPui2IC7UmxEPap3eaG5GW1XP+soN5A5qZlB3aln9y0agYVdabnlX/3faXXvuH
mOnRpCHZ5bNVAPkAc7zs
=ft4k
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.