diff mbox series

Fix PR82757

Message ID alpine.LSU.2.20.1710301347020.8202@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR82757 | expand

Commit Message

Richard Biener Oct. 30, 2017, 12:48 p.m. UTC
The following fixes the gold linker still recognizing LTO bytecode
via an UNDEF __gnu_lto_* symbol.  So on "removal" of the symbol
make sure to strip two leading _s.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-10-30  Richard Biener  <rguenther@suse.de>

	PR lto/82757
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Strip two leading _s from the __gnu_lto_* symbols.

Comments

Jakub Jelinek Oct. 30, 2017, 12:54 p.m. UTC | #1
On Mon, Oct 30, 2017 at 01:48:00PM +0100, Richard Biener wrote:
> 
> The following fixes the gold linker still recognizing LTO bytecode
> via an UNDEF __gnu_lto_* symbol.  So on "removal" of the symbol
> make sure to strip two leading _s.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Doesn't that make a gnu_lto_* symbol defined in the same shared library or
binary hidden, even when not hidden in the source?  Or are there . or $
characters in the name that make that impossible?

> 2017-10-30  Richard Biener  <rguenther@suse.de>
> 
> 	PR lto/82757
> 	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
> 	Strip two leading _s from the __gnu_lto_* symbols.
> 
> Index: libiberty/simple-object-elf.c
> ===================================================================
> --- libiberty/simple-object-elf.c	(revision 254211)
> +++ libiberty/simple-object-elf.c	(working copy)
> @@ -1384,7 +1384,12 @@ simple_object_elf_copy_lto_debug_section
>  				  && p[1] == '_'
>  				  && strncmp (p + (p[2] == '_'),
>  					      "__gnu_lto_", 10) == 0)
> -				other = STV_HIDDEN;
> +				{
> +				  other = STV_HIDDEN;
> +				  ELF_SET_FIELD (type_functions, ei_class, Sym,
> +						 ent, st_name, Elf_Word,
> +						 st_name + 2);
> +				}
>  			    }
>  			}
>  		      *st_other = other;

	Jakub
Richard Biener Oct. 30, 2017, 12:57 p.m. UTC | #2
On Mon, 30 Oct 2017, Jakub Jelinek wrote:

> On Mon, Oct 30, 2017 at 01:48:00PM +0100, Richard Biener wrote:
> > 
> > The following fixes the gold linker still recognizing LTO bytecode
> > via an UNDEF __gnu_lto_* symbol.  So on "removal" of the symbol
> > make sure to strip two leading _s.
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
> 
> Doesn't that make a gnu_lto_* symbol defined in the same shared library or
> binary hidden, even when not hidden in the source?  Or are there . or $
> characters in the name that make that impossible?

Asked Alan the same question and he said

"Of course on x86_64, you'll start off with "__gnu_lto_", skip two chars 
to give "gnu_lto_", which also ought to be fine.  Even if it matches some 
user symbol."

I also said that I'll likely end up writing proper symbol removal
code ... (but not during stage1).

Richard.
diff mbox series

Patch

Index: libiberty/simple-object-elf.c
===================================================================
--- libiberty/simple-object-elf.c	(revision 254211)
+++ libiberty/simple-object-elf.c	(working copy)
@@ -1384,7 +1384,12 @@  simple_object_elf_copy_lto_debug_section
 				  && p[1] == '_'
 				  && strncmp (p + (p[2] == '_'),
 					      "__gnu_lto_", 10) == 0)
-				other = STV_HIDDEN;
+				{
+				  other = STV_HIDDEN;
+				  ELF_SET_FIELD (type_functions, ei_class, Sym,
+						 ent, st_name, Elf_Word,
+						 st_name + 2);
+				}
 			    }
 			}
 		      *st_other = other;