2019-10-07 16:58:30 +01:00
|
|
|
--- a/mesonbuild/linkers.py
|
|
|
|
+++ b/mesonbuild/linkers.py
|
|
|
|
@@ -527,8 +527,10 @@ class GnuLikeDynamicLinkerMixin:
|
|
|
|
# In order to avoid relinking for RPATH removal, the binary needs to contain just
|
|
|
|
# enough space in the ELF header to hold the final installation RPATH.
|
|
|
|
paths = ':'.join(all_paths)
|
|
|
|
- if len(paths) < len(install_rpath):
|
|
|
|
- padding = 'X' * (len(install_rpath) - len(paths))
|
|
|
|
+ store_paths = ':'.join(filter(lambda path: path.startswith('@storeDir@'), all_paths))
|
|
|
|
+ extra_space_needed = len(install_rpath + (':' if install_rpath and store_paths else '') + store_paths) - len(paths)
|
|
|
|
+ if extra_space_needed > 0:
|
|
|
|
+ padding = 'X' * extra_space_needed
|
|
|
|
if not paths:
|
|
|
|
paths = padding
|
|
|
|
else:
|
|
|
|
@@ -902,8 +904,10 @@ class SolarisDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
|
|
|
|
# In order to avoid relinking for RPATH removal, the binary needs to contain just
|
|
|
|
# enough space in the ELF header to hold the final installation RPATH.
|
|
|
|
paths = ':'.join(all_paths)
|
|
|
|
- if len(paths) < len(install_rpath):
|
|
|
|
- padding = 'X' * (len(install_rpath) - len(paths))
|
|
|
|
+ store_paths = ':'.join(filter(lambda path: path.startswith('@storeDir@'), all_paths))
|
|
|
|
+ extra_space_needed = len(install_rpath + (':' if install_rpath and store_paths else '') + store_paths) - len(paths)
|
|
|
|
+ if extra_space_needed > 0:
|
|
|
|
+ padding = 'X' * extra_space_needed
|
|
|
|
if not paths:
|
|
|
|
paths = padding
|
|
|
|
else:
|
2018-02-23 00:42:35 +00:00
|
|
|
--- a/mesonbuild/scripts/depfixer.py
|
|
|
|
+++ b/mesonbuild/scripts/depfixer.py
|
2019-10-07 16:58:30 +01:00
|
|
|
@@ -303,6 +303,14 @@ class Elf(DataSizes):
|
2018-02-23 00:42:35 +00:00
|
|
|
return
|
|
|
|
self.bf.seek(rp_off)
|
|
|
|
old_rpath = self.read_str()
|
|
|
|
+
|
|
|
|
+ if new_rpath:
|
|
|
|
+ new_rpath += b':'
|
|
|
|
+ else:
|
|
|
|
+ new_rpath = b''
|
|
|
|
+
|
|
|
|
+ new_rpath += b':'.join(filter(lambda path: path.startswith(b'@storeDir@'), old_rpath.split(b':')))
|
|
|
|
+
|
|
|
|
if len(old_rpath) < len(new_rpath):
|
|
|
|
sys.exit("New rpath must not be longer than the old one.")
|
|
|
|
# The linker does read-only string deduplication. If there is a
|
2019-10-07 16:58:30 +01:00
|
|
|
@@ -316,6 +324,10 @@ class Elf(DataSizes):
|
2018-09-02 18:28:49 +01:00
|
|
|
if not new_rpath:
|
|
|
|
self.remove_rpath_entry(entrynum)
|
|
|
|
else:
|
|
|
|
+ # clean old rpath to avoid stale references
|
|
|
|
+ # (see https://github.com/NixOS/nixpkgs/pull/46020)
|
|
|
|
+ self.bf.seek(rp_off)
|
|
|
|
+ self.bf.write(b'\0'*len(old_rpath))
|
|
|
|
self.bf.seek(rp_off)
|
|
|
|
self.bf.write(new_rpath)
|
|
|
|
self.bf.write(b'\0')
|