55 lines
2.4 KiB
Diff
55 lines
2.4 KiB
Diff
|
|
# HG changeset patch
|
|
# User Mike Hommey <mh+mozilla@glandium.org>
|
|
# Date 1691703966 0
|
|
# Node ID 721a5102bc50cccae86d05d5052501845a6fd7bb
|
|
# Parent 24195ef5e1a7ff8f510159dca76ddbc92c5dce6c
|
|
Bug 1847697 - Don't use -z,pack-relative-relocs when it would lead to a ld.so error. r=firefox-build-system-reviewers,ahochheiden
|
|
|
|
Differential Revision: https://phabricator.services.mozilla.com/D185712
|
|
|
|
diff --git a/toolkit/moz.configure b/toolkit/moz.configure
|
|
--- a/toolkit/moz.configure
|
|
+++ b/toolkit/moz.configure
|
|
@@ -1595,26 +1595,34 @@ with only_when("--enable-compile-environ
|
|
onerror=lambda: None,
|
|
)
|
|
is not None
|
|
):
|
|
# BFD ld ignores options it doesn't understand. So check
|
|
# that we did get packed relative relocations (DT_RELR).
|
|
env = os.environ.copy()
|
|
env["LANG"] = "C"
|
|
- dyn = check_cmd_output(readelf, "-d", path, env=env)
|
|
+ dyn = check_cmd_output(readelf, "-d", path, env=env).splitlines()
|
|
tags = [
|
|
- int(l.split()[0], 16)
|
|
- for l in dyn.splitlines()
|
|
- if l.strip().startswith("0x")
|
|
+ int(l.split()[0], 16) for l in dyn if l.strip().startswith("0x")
|
|
]
|
|
# Older versions of readelf don't know about DT_RELR but will
|
|
# still display the tag number.
|
|
if 0x23 in tags:
|
|
- return pack_rel_relocs
|
|
+ needed = [l for l in dyn if l.split()[1] == "(NEEDED)"]
|
|
+ is_glibc = any(l.endswith("[libc.so.6]") for l in needed)
|
|
+ # The mold linker doesn't add a GLIBC_ABI_DT_RELR version
|
|
+ # dependency, which ld.so doesn't like.
|
|
+ # https://github.com/rui314/mold/issues/653#issuecomment-1670274638
|
|
+ if is_glibc:
|
|
+ versions = check_cmd_output(readelf, "-V", path, env=env)
|
|
+ if "GLIBC_ABI_DT_RELR" in versions.split():
|
|
+ return pack_rel_relocs
|
|
+ else:
|
|
+ return pack_rel_relocs
|
|
finally:
|
|
try:
|
|
os.remove(path)
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
add_old_configure_assignment("PACK_REL_RELOC_FLAGS", pack_relative_relocs)
|
|
|
|
|