elf: Don't make forced local symbol dynamic for PIC outputs

Message ID 20200607180822.672906-1-hjl.tools@gmail.com
State New
Headers show
Series
  • elf: Don't make forced local symbol dynamic for PIC outputs
Related show

Commit Message

Cooper Qu via Binutils June 7, 2020, 6:08 p.m.
For:

  /* True if this target has relocatable executables, so needs dynamic
     section symbols.  */
  bfd_boolean is_relocatable_executable;

there is no need to make forced local symbol dynamic for PIC outputs.
This fixes:

FAIL: ld-elf/pr11304
FAIL: ld exclude symbols from archive - --exclude-libs ALL
FAIL: ld exclude symbols from archive - --exclude-libs foo,libexclude.a
FAIL: ld exclude symbols from archive - --exclude-libs foo:libexclude.a
FAIL: ld exclude symbols from archive - --exclude-libs libexclude
FAIL: ld exclude symbols from archive - --exclude-libs libexclude.a

for tic6x-elf.

	PR ld/26090
	* elflink.c (bfd_elf_link_record_dynamic_symbol): Don't make
	forced local symbol dynamic for PIC outputs.
---
 bfd/elflink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.26.2

Comments

Cooper Qu via Binutils June 10, 2020, 9:51 a.m. | #1
On Sun, Jun 07, 2020 at 11:08:22AM -0700, H.J. Lu via Binutils wrote:
> For:

> 

>   /* True if this target has relocatable executables, so needs dynamic

>      section symbols.  */

>   bfd_boolean is_relocatable_executable;

> 

> there is no need to make forced local symbol dynamic for PIC outputs.


On what do you base that claim?  I'm looking for a better reason than
the name of the variable indicates executables.  It might be that
targets with is_relocatable_executable set also need special treatment
for shared libraries.

-- 
Alan Modra
Australia Development Lab, IBM
Cooper Qu via Binutils June 10, 2020, 1 p.m. | #2
On Wed, Jun 10, 2020 at 2:51 AM Alan Modra <amodra@gmail.com> wrote:
>

> On Sun, Jun 07, 2020 at 11:08:22AM -0700, H.J. Lu via Binutils wrote:

> > For:

> >

> >   /* True if this target has relocatable executables, so needs dynamic

> >      section symbols.  */

> >   bfd_boolean is_relocatable_executable;

> >

> > there is no need to make forced local symbol dynamic for PIC outputs.

>

> On what do you base that claim?  I'm looking for a better reason than

> the name of the variable indicates executables.  It might be that

> targets with is_relocatable_executable set also need special treatment

> for shared libraries.


Relocatable executables come from VxWorks.  Let's ask a VxWorks
expert.  Olivier, does VxWorks require local and section symbols dynamic
for position independent outputs, like PIE or shared library?


-- 
H.J.
Olivier Hainque June 11, 2020, 1:07 p.m. | #3
Hello H.J.

> On 10 Jun 2020, at 15:00, H.J. Lu <hjl.tools@gmail.com> wrote:


> Relocatable executables come from VxWorks.  Let's ask a VxWorks

> expert.  Olivier, does VxWorks require local and section symbols dynamic

> for position independent outputs, like PIE or shared library?


I don't think so. At least on ppc vx6 and vx7 + arm vx6,
the system toolchain doesn't do that.

But AFAICS, is_relocatable_executable in binutils is
not a VxWorks thing. It seems to be more a SymbianOS thing.

There are very few places where the flag is set. One of them
is elf32_arm_symbian_link_hash_table_create, and if I'm not
mistaken, the flag was introduced from

  https://sourceware.org/legacy-ml/binutils/2005-02/msg00174.html

which starts with

 "arm-*-symbianelf executables are relocatable.
 This has a few implications:"

Olivier
Cooper Qu via Binutils June 11, 2020, 1:23 p.m. | #4
On Thu, Jun 11, 2020 at 6:07 AM Olivier Hainque <hainque@adacore.com> wrote:
>

> Hello H.J.

>

> > On 10 Jun 2020, at 15:00, H.J. Lu <hjl.tools@gmail.com> wrote:

>

> > Relocatable executables come from VxWorks.  Let's ask a VxWorks

> > expert.  Olivier, does VxWorks require local and section symbols dynamic

> > for position independent outputs, like PIE or shared library?

>

> I don't think so. At least on ppc vx6 and vx7 + arm vx6,

> the system toolchain doesn't do that.

>

> But AFAICS, is_relocatable_executable in binutils is

> not a VxWorks thing. It seems to be more a SymbianOS thing.

>

> There are very few places where the flag is set. One of them

> is elf32_arm_symbian_link_hash_table_create, and if I'm not

> mistaken, the flag was introduced from

>

>   https://sourceware.org/legacy-ml/binutils/2005-02/msg00174.html

>

> which starts with

>

>  "arm-*-symbianelf executables are relocatable.

>  This has a few implications:"


Does SymbianOS run on tic6x?

commit ac14530735340ebde54e9d536e3a0fd3e82f36db
Author: Bernd Schmidt <bernds@codesourcery.com>
Date:   Thu Mar 31 08:58:28 2011 +0000

    include/elf/
            * tic6x.h (R_C6000_JUMP_SPLOT, R_C6000_EHTYPE,
            R_C6000_PCR_H16, R_C6000_PCR_L16): New relocs.
            (SHN_TIC6X_SCOMMON): Define.

added is_relocatable_executable for tic6x.  Bernd, is it required?

-- 
H.J.

Patch

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 60a3c2216f..b5ff4cde58 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -517,7 +517,8 @@  bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *info,
 	      && h->root.type != bfd_link_hash_undefweak)
 	    {
 	      h->forced_local = 1;
-	      if (!elf_hash_table (info)->is_relocatable_executable)
+	      if (bfd_link_pic (info)
+		  || !elf_hash_table (info)->is_relocatable_executable)
 		return TRUE;
 	    }