Subject: meson: breaks DT_MIPS_RLD_MAP_REL elf entry when removing RPATH entry
Date: Sun, 23 Oct 2016 21:23:51 +0200
Package: meson
Version: 0.35.1-1
Severity: important
Tags: patch upstream
The depfixer.py script in meson has the possibility to remove RPATH or
RUNPATH entries. It does this by moving all of the other dynamic tags up
one entry. Unfortunately some of the tags are relative to the offset of
the tag within the executable. That is at least the case of the
DT_MIPS_RLD_MAP_REL tag on MIPS, and it results into broken binaries
which segfaults.
The patch below fixes the issue by adjusting the value of the
DT_MIPS_RLD_MAP_REL tag when it is shifted, the same way it is done in
chrpath.
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py
index 7124c6f..34fb2f7 100755
--- a/mesonbuild/scripts/depfixer.py
+++ b/mesonbuild/scripts/depfixer.py
@@ -23,6 +23,7 @@ DT_RPATH = 15
DT_RUNPATH = 29
DT_STRTAB = 5
DT_SONAME = 14
+DT_MIPS_RLD_MAP_REL = 1879048245
class DataSizes():
def __init__(self, ptrsize, is_le):
@@ -307,6 +308,11 @@ class Elf(DataSizes):
rpentry.d_tag = 0
self.dynamic = self.dynamic[:i] + self.dynamic[i+1:] + [rpentry]
break;
+ # DT_MIPS_RLD_MAP_REL is relative to the offset of the tag. Adjust it consequently.
+ for entry in self.dynamic[i:]:
+ if entry.d_tag == DT_MIPS_RLD_MAP_REL:
+ entry.val += 2 * (self.ptrsize // 8)
+ break
self.bf.seek(sec.sh_offset)
for entry in self.dynamic:
entry.write(self.bf)
-- System Information:
Debian Release: stretch/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: mips64el (mips64)
Kernel: Linux 4.7.0-1-5kc-malta
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Acknowledgement sent
to Jussi Pakkanen <[email protected]>:
Extra info received and forwarded to list.
(Sun, 23 Oct 2016 19:51:02 GMT) (full text, mbox, link).
On Sun, Oct 23, 2016 at 10:23 PM, Aurelien Jarno <[email protected]> wrote:
> The patch below fixes the issue by adjusting the value of the
> DT_MIPS_RLD_MAP_REL tag when it is shifted, the same way it is done in
> chrpath.
Created an upstream MR here: https://github.com/mesonbuild/meson/pull/946
Is it possible that this sort of adjustment might break on other
entries as well? Is there an alternative way of doing this? AFAICR I
tried to see if there were a "dummy" entry we could put in rpath's
place so the others would not move but could not really find one.
Thanks,
Acknowledgement sent
to Aurelien Jarno <[email protected]>:
Extra info received and forwarded to list. Copy sent to Jussi Pakkanen <[email protected]>.
(Sun, 23 Oct 2016 22:18:03 GMT) (full text, mbox, link).
On 2016-10-23 22:48, Jussi Pakkanen wrote:
> On Sun, Oct 23, 2016 at 10:23 PM, Aurelien Jarno <[email protected]> wrote:
>
> > The patch below fixes the issue by adjusting the value of the
> > DT_MIPS_RLD_MAP_REL tag when it is shifted, the same way it is done in
> > chrpath.
>
> Created an upstream MR here: https://github.com/mesonbuild/meson/pull/946
Thanks!
> Is it possible that this sort of adjustment might break on other
> entries as well? Is there an alternative way of doing this? AFAICR I
It is possible, that said I don't have another example. At least on MIPS
it seems the only one.
> tried to see if there were a "dummy" entry we could put in rpath's
> place so the others would not move but could not really find one.
The strategy adopted by meson is the same than the one adopted by
chrpath, and chrpath also adjusts the value of DT_MIPS_RLD_MAP_REL.
I don't know if there is another way to do that, at least I don't
think there is another obvious way to do it.
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
[email protected]http://www.aurel32.net
Acknowledgement sent
to Jussi Pakkanen <[email protected]>:
Extra info received and forwarded to list.
(Mon, 24 Oct 2016 19:24:04 GMT) (full text, mbox, link).
> The strategy adopted by meson is the same than the one adopted by
> chrpath, and chrpath also adjusts the value of DT_MIPS_RLD_MAP_REL.
> I don't know if there is another way to do that, at least I don't
> think there is another obvious way to do it.
Ok, thanks. Committed to master and will be in the next release which
will be in a week or two.
Acknowledgement sent
to Aurelien Jarno <[email protected]>:
Extra info received and forwarded to list. Copy sent to Jussi Pakkanen <[email protected]>.
(Tue, 25 Oct 2016 05:21:08 GMT) (full text, mbox, link).
On 2016-10-24 22:20, Jussi Pakkanen wrote:
> > The strategy adopted by meson is the same than the one adopted by
> > chrpath, and chrpath also adjusts the value of DT_MIPS_RLD_MAP_REL.
> > I don't know if there is another way to do that, at least I don't
> > think there is another obvious way to do it.
>
> Ok, thanks. Committed to master and will be in the next release which
> will be in a week or two.
Thanks!
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
[email protected]http://www.aurel32.net
Le 2016-10-23 21:23, Aurelien Jarno a écrit :
> Package: meson
> Version: 0.35.1-1
> Severity: important
> Tags: patch upstream
>
> The depfixer.py script in meson has the possibility to remove RPATH or
> RUNPATH entries. It does this by moving all of the other dynamic tags
> up
> one entry. Unfortunately some of the tags are relative to the offset of
> the tag within the executable. That is at least the case of the
> DT_MIPS_RLD_MAP_REL tag on MIPS, and it results into broken binaries
> which segfaults.
>
> The patch below fixes the issue by adjusting the value of the
> DT_MIPS_RLD_MAP_REL tag when it is shifted, the same way it is done in
> chrpath.
>
> diff --git a/mesonbuild/scripts/depfixer.py
> b/mesonbuild/scripts/depfixer.py
> index 7124c6f..34fb2f7 100755
> --- a/mesonbuild/scripts/depfixer.py
> +++ b/mesonbuild/scripts/depfixer.py
> @@ -23,6 +23,7 @@ DT_RPATH = 15
> DT_RUNPATH = 29
> DT_STRTAB = 5
> DT_SONAME = 14
> +DT_MIPS_RLD_MAP_REL = 1879048245
>
> class DataSizes():
> def __init__(self, ptrsize, is_le):
> @@ -307,6 +308,11 @@ class Elf(DataSizes):
> rpentry.d_tag = 0
> self.dynamic = self.dynamic[:i] + self.dynamic[i+1:]
> + [rpentry]
> break;
> + # DT_MIPS_RLD_MAP_REL is relative to the offset of the tag.
> Adjust it consequently.
> + for entry in self.dynamic[i:]:
> + if entry.d_tag == DT_MIPS_RLD_MAP_REL:
> + entry.val += 2 * (self.ptrsize // 8)
> + break
> self.bf.seek(sec.sh_offset)
> for entry in self.dynamic:
> entry.write(self.bf)
>
> -- System Information:
> Debian Release: stretch/sid
> APT prefers testing
> APT policy: (500, 'testing')
> Architecture: mips64el (mips64)
>
> Kernel: Linux 4.7.0-1-5kc-malta
> Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
Reply sent
to Jussi Pakkanen <[email protected]>:
You have taken responsibility.
(Mon, 14 Nov 2016 21:51:03 GMT) (full text, mbox, link).
Notification sent
to Aurelien Jarno <[email protected]>:
Bug acknowledged by developer.
(Mon, 14 Nov 2016 21:51:03 GMT) (full text, mbox, link).
Source: meson
Source-Version: 0.36.0-1
We believe that the bug you reported is fixed in the latest version of
meson, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Jussi Pakkanen <[email protected]> (supplier of updated meson package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Format: 1.8
Date: Mon, 14 Nov 2016 20:12:41 +0200
Source: meson
Binary: meson
Architecture: source all
Version: 0.36.0-1
Distribution: unstable
Urgency: medium
Maintainer: Jussi Pakkanen <[email protected]>
Changed-By: Jussi Pakkanen <[email protected]>
Description:
meson - high-productivity build system
Closes: 841846
Changes:
meson (0.36.0-1) unstable; urgency=medium
.
* New upstream release. Closes: #841846.
* Added build dep to itstool, which is needed by new tests.
Checksums-Sha1:
ae4226a5a679ddcd5abdb91aa2310e24b428150a 2246 meson_0.36.0-1.dsc
9b229c7526bccc33a43f903877356ed510b65685 458992 meson_0.36.0.orig.tar.gz
0d438035fafe5c2b05630649489469f4abd7d40f 8992 meson_0.36.0-1.debian.tar.xz
cefe9bf741575e7c3063287b2f809da16f0c2b5f 23427 meson_0.36.0-1_20161114T212207z-79b912ac.buildinfo
379335657349a2342c65984d74f6457a102f8979 138930 meson_0.36.0-1_all.deb
Checksums-Sha256:
434ecc0ef1df8887b18cb9817789f3f7f987d6f5884b3367d1ffc9cfc5ffe127 2246 meson_0.36.0-1.dsc
dc087ec40dacb5e256e6ee6467f2d004faf4ef284d3c1ce5e89faa1e16540950 458992 meson_0.36.0.orig.tar.gz
fd2ed702c109287a82c604d7c6d0ac7827ec5fd60619140c2cd5180b719cf235 8992 meson_0.36.0-1.debian.tar.xz
35611c39ed33e95d025667d2cc389202eb1b3135c315a51f9f7714eb871f5687 23427 meson_0.36.0-1_20161114T212207z-79b912ac.buildinfo
7a9f34484f90e113fd31cdad4131c3736911ff0d8021e2e12130aabb9257ed56 138930 meson_0.36.0-1_all.deb
Files:
eed69b17849997cf8729da81aa631dfb 2246 devel optional meson_0.36.0-1.dsc
dfdd190c5f10a67bb40e6cf93944dd43 458992 devel optional meson_0.36.0.orig.tar.gz
65e4a09fb0d86bae287e6e5c3e8ed64d 8992 devel optional meson_0.36.0-1.debian.tar.xz
79b912ac0f22c3afee014041d47da86b 23427 devel optional meson_0.36.0-1_20161114T212207z-79b912ac.buildinfo
4667547d2c1154deb362786882b75870 138930 devel optional meson_0.36.0-1_all.deb
-----BEGIN PGP SIGNATURE-----
iQIcBAEBCAAGBQJYKiseAAoJENFO8V2v4RNH9nEQAIjczNvPQTHxT0jZiSzr3D16
3nbf77S7ySjo6ZpnJyzyn4mcSVufgTl2nln2qBysDVBKmSKrrTdHqC09hDNbmQDa
ZOBBteVwV8it+pDNfpTUn0Gh6WW+FGIve+ROFjO7bkQOoCPVbKiBULtbgDXWurY0
GcFPkV6pxGKCLHfDYzZnnukWzLzRsbUTyhoPpYgyjnodbr5Ow1mSazzbX+D5ZtWf
wXkjs1nEsxD5/Ndn+B8lXvQg9nqZxh40Vue5/S01WsXeSFDbsGlQxeuNxaCGTlL1
Ywzc0oqqicB9kulyu2oHC7L6ZmElQgaA9OxbSANRcMbWYcAJSyFTl4aMd/BPk5yb
gnbHJk/+1rlEV90Ucm3Al6EXfFZdWsHZ632o4CiAfZtg35PwERORolNBP3u3UL1/
EpowttjF1tPTyyl6bVc1+2pzbCu+CcYxzp4sgo0bt+WgcQyDKnmtbnj2IFxK4kgy
eX71Q8Z8GgKD6z+ghTdGFlSkkbOr/64P4LM7kfexTfcGgG0/WAmlz7G0x+iGEH0z
PjLiNFC+Qjrk1H4FiM/qaBzMXy02b99Naaa1OuyJlMbx08Wd9OrB9MO85KE6Q6ZO
HnLIskOvtZzrqBOo4GY5yM7si/P4iebVjT4bb/yPbYi/GnrIY09ui4d7wp3AxPwK
PAX7C8NtMwXk99hfoPvR
=Pw5R
-----END PGP SIGNATURE-----
Debbugs is free software and licensed under the terms of the GNU General
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.