PR28751 mbind2a / mbind2b regressions on powerpc*-linux
Alan Modra
amodra@gmail.com
Fri Jan 14 11:45:50 GMT 2022
Fixes failures introduced with commit 74e315dbfe52. PowerPC64 linux
often runs with 64k page size. Reducing the page size to 16k results
in binaries that won't run.
include/
* bfdlink.h (struct bfd_link_info): Add commonpagesize_is_set.
ld/
PR 28751
* emultempl/elf.em (handle_option): Set commonpagesize_is_set.
* ldelf.c (ldelf_after_parse): Don't error when only one of
-z max-page-size or -z common-page-size is given, correct the
other value to make it sane.
* testsuite/ld-elf/elf.exp (mbind2a, mbind2b): Do not pass
-z max-page-size.
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 92e3e32360b..69fc9d33ff4 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -532,6 +532,9 @@ struct bfd_link_info
/* TRUE if maxpagesize is set on command-line. */
unsigned int maxpagesize_is_set : 1;
+ /* TRUE if commonpagesize is set on command-line. */
+ unsigned int commonpagesize_is_set : 1;
+
/* Char that may appear as the first char of a symbol, but should be
skipped (like symbol_leading_char) when looking up symbols in
wrap_hash. Used by PowerPC Linux for 'dot' symbols. */
diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
index 59775260b06..7325872e1d9 100644
--- a/ld/emultempl/elf.em
+++ b/ld/emultempl/elf.em
@@ -731,6 +731,7 @@ fragment <<EOF
|| (link_info.commonpagesize & (link_info.commonpagesize - 1)) != 0)
einfo (_("%F%P: invalid common page size \`%s'\n"),
optarg + 17);
+ link_info.commonpagesize_is_set = true;
}
else if (startswith (optarg, "stack-size="))
{
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 7a1a553cae7..799f7796017 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -82,8 +82,15 @@ ldelf_after_parse (void)
after_parse_default ();
if (link_info.commonpagesize > link_info.maxpagesize)
- einfo (_("%F%P: common page size (0x%v) > maximum page size (0x%v)\n"),
- link_info.commonpagesize, link_info.maxpagesize);
+ {
+ if (!link_info.commonpagesize_is_set)
+ link_info.commonpagesize = link_info.maxpagesize;
+ else if (!link_info.maxpagesize_is_set)
+ link_info.maxpagesize = link_info.commonpagesize;
+ else
+ einfo (_("%F%P: common page size (0x%v) > maximum page size (0x%v)\n"),
+ link_info.commonpagesize, link_info.maxpagesize);
+ }
}
/* Handle the generation of DT_NEEDED tags. */
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 16128c2989f..119908cda4e 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -365,7 +365,7 @@ if { [istarget *-*-linux*]
run_ld_link_exec_tests [list \
[list \
"Run mbind2a" \
- "$NOPIE_LDFLAGS -Wl,-z,common-page-size=0x4000,-z,max-page-size=0x4000" \
+ "$NOPIE_LDFLAGS -Wl,-z,common-page-size=0x4000" \
"" \
{ mbind2a.s mbind2b.c } \
"mbind2a" \
@@ -374,7 +374,7 @@ if { [istarget *-*-linux*]
] \
[list \
"Run mbind2b" \
- "-static -Wl,-z,common-page-size=0x4000,-z,max-page-size=0x4000" \
+ "-static -Wl,-z,common-page-size=0x4000" \
"" \
{ mbind2a.s mbind2b.c } \
"mbind2b" \
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list