[PATCH] ld: Ignore .note.gnu.build-id when placing orphaned notes

H.J. Lu hjl.tools@gmail.com
Fri Sep 27 04:26:15 GMT 2024


On Fri, Sep 27, 2024 at 8:33 AM Alan Modra <amodra@gmail.com> wrote:
>
> On Fri, Sep 27, 2024 at 08:06:31AM +0800, H.J. Lu wrote:
> > On Fri, Sep 27, 2024, 8:04 AM Alan Modra <amodra@gmail.com> wrote:
> >
> > > On Fri, Sep 27, 2024 at 07:06:30AM +0800, H.J. Lu wrote:
> > > > Since -z separate-code is only supported with shared library and orphaned
> > >
> > > Is there a reason why we don't support "-z separate-code", "-z common",
> > > and "-z text" unless targets also support shared libraries?
> > >
> > > It seems to me that there is a misplaced "fi" in elf.em.
> > >
> >
> > Good question.  But I don't have an answer for this.
>
> Well, it seems like the required scripts are generated, so..
>
> From 428f3561bc16dfc2944ee641201acdd166315aa2 Mon Sep 17 00:00:00 2001
> From: Alan Modra <amodra@gmail.com>
> Date: Fri, 27 Sep 2024 09:53:10 +0930
> Subject: Enable -z separate-code, -z common and -z text for more targets
>
> Fix a mis-placed "fi".
>
> diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
> index 863657e12f5..2e865728587 100644
> --- a/ld/emultempl/elf.em
> +++ b/ld/emultempl/elf.em
> @@ -1084,6 +1084,7 @@ fragment <<EOF
>         link_info.relro = false;
>  EOF
>  fi
> +fi
>  fragment <<EOF
>        else if (strcmp (optarg, "separate-code") == 0)
>         link_info.separate_code = true;
> @@ -1100,7 +1101,6 @@ fragment <<EOF
>        else if (strcmp (optarg, "textoff") == 0)
>         link_info.textrel_check = textrel_check_none;
>  EOF
> -fi
>
>  if test -n "$PARSE_AND_LIST_ARGS_CASE_Z" ; then
>  fragment <<EOF

I don't think -z separate-code works ASAS for targets without shared
library support.  On cris-elf, ld-elf/pr23658-1e passes.  But ld-elf/pr23658-1e
generates:

 Section to Segment mapping:
  Segment Sections...
   00     .note.gnu.build-id .text .note.4 .note.1 .note.2 .note.3
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is wrong for -z separate-code.  This may be another
symptom for PR ld/32191.

   01     .note.gnu.build-id
   02     .note.4 .note.1
   03     .note.2 .note.3


> diff --git a/ld/testsuite/ld-elf/pr22393-1e.d b/ld/testsuite/ld-elf/pr22393-1e.d
> index 51d74fa1381..55f7e9a6e4e 100644
> --- a/ld/testsuite/ld-elf/pr22393-1e.d
> +++ b/ld/testsuite/ld-elf/pr22393-1e.d
> @@ -2,7 +2,7 @@
>  #ld: -z separate-code
>  #readelf: -l --wide
>  #target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi
> -#xfail: h8300-*-* rx-*-linux*
> +#xfail: rx-*-linux*
>
>  #failif
>  #...
> diff --git a/ld/testsuite/ld-elf/pr22393-1f.d b/ld/testsuite/ld-elf/pr22393-1f.d
> index 2a44955d0f1..bc61b639658 100644
> --- a/ld/testsuite/ld-elf/pr22393-1f.d
> +++ b/ld/testsuite/ld-elf/pr22393-1f.d
> @@ -2,7 +2,7 @@
>  #ld: -z separate-code
>  #readelf: -l --wide
>  #target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi
> -#xfail: h8300-*-* rx-*-linux*
> +#xfail: rx-*-linux*
>
>  #failif
>  #...
> diff --git a/ld/testsuite/ld-elf/pr30508.d b/ld/testsuite/ld-elf/pr30508.d
> index 325ff40f562..16927809030 100644
> --- a/ld/testsuite/ld-elf/pr30508.d
> +++ b/ld/testsuite/ld-elf/pr30508.d
> @@ -2,7 +2,7 @@
>  #objcopy_linked_file: -R .foo
>  #readelf: -lW
>  #target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi
> -#xfail: h8300-*-* mips*-*-* rx-*-linux*
> +#xfail: mips*-*-* rx-*-linux*
>
>  #...
>   Section to Segment mapping:
>
>
> --
> Alan Modra



-- 
H.J.


More information about the Binutils mailing list