diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-13 23:27:40 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-17 12:48:54 +0300 |
commit | 0e47e74a77447575cbabd71315481c6dd9632601 (patch) | |
tree | 368de0c60806fdb1d1109aabdc7dc8abae0b9c6c /mesonbuild/scripts/depfixer.py | |
parent | 0e45134dee09b12005c028aee066b04ff86228e5 (diff) | |
download | meson-0e47e74a77447575cbabd71315481c6dd9632601.zip meson-0e47e74a77447575cbabd71315481c6dd9632601.tar.gz meson-0e47e74a77447575cbabd71315481c6dd9632601.tar.bz2 |
Do not obliterate old rpath because it might be used due to read only data sharing. Closes #1619.
Diffstat (limited to 'mesonbuild/scripts/depfixer.py')
-rw-r--r-- | mesonbuild/scripts/depfixer.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 1404619..16050d7 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -297,11 +297,20 @@ class Elf(DataSizes): old_rpath = self.read_str() if len(old_rpath) < len(new_rpath): sys.exit("New rpath must not be longer than the old one.") - self.bf.seek(rp_off) - self.bf.write(new_rpath) - self.bf.write(b'\0' * (len(old_rpath) - len(new_rpath) + 1)) + # The linker does read-only string deduplication. If there is a + # string that shares a suffix with the rpath, they might get + # dedupped. This means changing the rpath string might break something + # completely unrelated. This has already happened once with X.org. + # Thus we want to keep this change as small as possible to minimize + # the chance of obliterating other strings. It might still happen + # but our behaviour is identical to what chrpath does and it has + # been in use for ages so based on that this should be rare. if len(new_rpath) == 0: self.remove_rpath_entry(entrynum) + else: + self.bf.seek(rp_off) + self.bf.write(new_rpath) + self.bf.write(b'\0') def remove_rpath_entry(self, entrynum): sec = self.find_section(b'.dynamic') |