[3/3] objcopy: zap ELF visibility when localizing symbols
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
Commit Message
The spec explicitly precludes STB_LOCAL together with STV_PROTECTED (and,
implicitly, STV_HIDDEN or STV_INTERNAL), so we better wouldn't (entirely
silently) write out symbols violating this.
@@ -1532,6 +1532,15 @@ is_hidden_symbol (asymbol *sym)
return false;
}
+static void
+clear_visibility (asymbol *sym)
+{
+ elf_symbol_type *elf_sym = elf_symbol_from (sym);
+
+ if (elf_sym != NULL)
+ elf_sym->internal_elf_sym.st_other &= ~ELF_ST_VISIBILITY (~0);
+}
+
/* Empty name is hopefully never a valid symbol name. */
static const char * empty_name = "";
@@ -1765,6 +1774,7 @@ filter_symbols (bfd *abfd, bfd *obfd, as
{
flags &= ~(BSF_GLOBAL | BSF_WEAK);
flags |= BSF_LOCAL;
+ clear_visibility (sym);
}
else if (!undefined
@@ -4,15 +4,15 @@
#name: --localize-hidden test 1
#warning_output: localize-hidden-1.l
#...
-0+1200 l .*\*ABS\* 0+ \.hidden Lhidden
-0+1300 l .*\*ABS\* 0+ \.internal Linternal
-0+1400 l .*\*ABS\* 0+ \.protected Lprotected
+0+1200 l .*\*ABS\* 0+ (\.hidden )?Lhidden
+0+1300 l .*\*ABS\* 0+ (\.internal )?Linternal
+0+1400 l .*\*ABS\* 0+ (\.protected )?Lprotected
0+1100 l .*\*ABS\* 0+ Ldefault
#...
-0+2200 l .*\*ABS\* 0+ \.hidden Ghidden
-0+2300 l .*\*ABS\* 0+ \.internal Ginternal
-0+3200 l .*\*ABS\* 0+ \.hidden Whidden
-0+3300 l .*\*ABS\* 0+ \.internal Winternal
+0+2200 l .*\*ABS\* 0+ Ghidden
+0+2300 l .*\*ABS\* 0+ Ginternal
+0+3200 l .*\*ABS\* 0+ Whidden
+0+3300 l .*\*ABS\* 0+ Winternal
#...
0+2100 g .*\*ABS\* 0+ Gdefault
0+2400 g .*\*ABS\* 0+ \.protected Gprotected