From: H.J. Lu Date: Sat, 9 Jan 2021 14:11:06 +0000 (-0800) Subject: ld/x86-64: Properly Handle -z lam-u48/lam-u57 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a94990bf64a82bdf73960fec1b47fef7c6a6ced;p=binutils-gdb.git ld/x86-64: Properly Handle -z lam-u48/lam-u57 Properly merge GNU properties for LAM_U48 and LAM_U57. bfd/ PR ld/27166 * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Handle -z lam-u48 and -z lam-u57. ld/ PR ld/27166 * testsuite/ld-x86-64/lam-u48.rd: New file. * testsuite/ld-x86-64/lam-u57.rd: Likewise. * testsuite/ld-x86-64/x86-64.exp: Add PR ld/27166 tests. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 560287fec95..d33445f87f3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2021-01-09 H.J. Lu + + PR ld/27166 + * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Handle + -z lam-u48 and -z lam-u57. + 2021-01-09 Nick Clifton * version.m4: Change to 2.36.50. diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index c47f48257ea..3a0dffc4e6e 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2449,8 +2449,15 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, features = GNU_PROPERTY_X86_FEATURE_1_IBT; if (htab->params->shstk) features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK; - /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and - GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ + if (htab->params->lam_u48) + features |= (GNU_PROPERTY_X86_FEATURE_1_LAM_U48 + | GNU_PROPERTY_X86_FEATURE_1_LAM_U57); + else if (htab->params->lam_u57) + features |= GNU_PROPERTY_X86_FEATURE_1_LAM_U57; + /* Add GNU_PROPERTY_X86_FEATURE_1_IBT, + GNU_PROPERTY_X86_FEATURE_1_SHSTK, + GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and + GNU_PROPERTY_X86_FEATURE_1_LAM_U57. */ aprop->u.number |= features; } updated = number != (unsigned int) aprop->u.number; @@ -2470,6 +2477,11 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, features = GNU_PROPERTY_X86_FEATURE_1_IBT; if (htab->params->shstk) features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK; + if (htab->params->lam_u48) + features |= (GNU_PROPERTY_X86_FEATURE_1_LAM_U48 + | GNU_PROPERTY_X86_FEATURE_1_LAM_U57); + else if (htab->params->lam_u57) + features |= GNU_PROPERTY_X86_FEATURE_1_LAM_U57; } if (features) { diff --git a/ld/ChangeLog b/ld/ChangeLog index 75bcad270d6..0628a4527a9 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2021-01-09 H.J. Lu + + PR ld/27166 + * testsuite/ld-x86-64/lam-u48.rd: New file. + * testsuite/ld-x86-64/lam-u57.rd: Likewise. + * testsuite/ld-x86-64/x86-64.exp: Add PR ld/27166 tests. + 2021-01-09 Nick Clifton * configure: Regenerate. diff --git a/ld/testsuite/ld-x86-64/lam-u48.rd b/ld/testsuite/ld-x86-64/lam-u48.rd new file mode 100644 index 00000000000..ad312627059 --- /dev/null +++ b/ld/testsuite/ld-x86-64/lam-u48.rd @@ -0,0 +1,6 @@ +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 +#... + Properties: x86 feature: .*LAM_U48, LAM_U57.* +#pass diff --git a/ld/testsuite/ld-x86-64/lam-u57.rd b/ld/testsuite/ld-x86-64/lam-u57.rd new file mode 100644 index 00000000000..8b77e6311c0 --- /dev/null +++ b/ld/testsuite/ld-x86-64/lam-u57.rd @@ -0,0 +1,6 @@ +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 +#... + Properties: x86 feature: .*LAM_U57.* +#pass diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 37a2e50341d..83fdaa7db65 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -1452,6 +1452,22 @@ if { [isnative] && [check_compiler_available] } { {{error_output "pr21997-1b.err"}} \ "pr21997-1b" \ ] \ + [list \ + "Build lam-u48.so" \ + "-shared -Wl,-z,lam-u48" \ + "" \ + {dummy.s} \ + {{readelf -n lam-u48.rd}} \ + "lam-u48.so" \ + ] \ + [list \ + "Build lam-u57.so" \ + "-shared -Wl,-z,lam-u57" \ + "" \ + {dummy.s} \ + {{readelf -n lam-u57.rd}} \ + "lam-u57.so" \ + ] \ ] }