[PATCH] Don't copy visibility for aliases
Jakub Jelinek
jakub@redhat.com
Fri Mar 1 03:48:00 GMT 2002
Hi!
Consider following assembly:
.globl a, b, c, d, e, f, g, h
.hidden a, d
a:
c:
e:
g:
b = a
d = c
f = e
h = g
.hidden e, h
Current gas will make:
4: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 a
5: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 b
6: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 c
7: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 d
8: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 e
9: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 f
10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 g
11: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 h
(ie. = copies visibility, and as there is no .normal there is no way
to undo this other than making sure .hidden comes last in the assembly).
This hit me in rtld.c, where I want to make _rtld_local .hidden (using
the new __attribute__((visibility("hidden"))) ) and _rtld_global be alias
to it, which is exported from ld.so.
With the following patch, gas will do the expected:
4: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 a
5: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 b
6: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 c
7: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 d
8: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 e
9: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 f
10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 g
11: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 h
(b and d's visibility are different).
Bootstrapped and regression tested on i386-redhat-linux.
Ok to commit?
2002-03-01 Jakub Jelinek <jakub@redhat.com>
* config/obj-elf.c (elf_copy_symbol_attributes): Don't copy
visibility.
(obj_frob_symbol): Copy visibility.
--- gas/config/obj-elf.c.jj Mon Jan 28 15:56:03 2002
+++ gas/config/obj-elf.c Fri Mar 1 12:29:09 2002
@@ -1408,7 +1408,9 @@ elf_copy_symbol_attributes (dest, src)
destelf->size = NULL;
}
S_SET_SIZE (dest, S_GET_SIZE (src));
- S_SET_OTHER (dest, S_GET_OTHER (src));
+ /* Don't copy visibility. */
+ S_SET_OTHER (dest, (ELF_ST_VISIBILITY (S_GET_OTHER (dest))
+ | (S_GET_OTHER (src) & ~ELF_ST_VISIBILITY (-1))));
}
void
@@ -1839,6 +1841,8 @@ elf_frob_symbol (symp, puntp)
/* This will copy over the size information. */
copy_symbol_attributes (symp2, symp);
+ S_SET_OTHER (symp2, S_GET_OTHER (symp));
+
if (S_IS_WEAK (symp))
S_SET_WEAK (symp2);
Jakub
More information about the Binutils
mailing list