https://sourceware.org/bugzilla/show_bug.cgi?id=21997
Bug ID: 21997
Summary: GNU_PROPERTY_NO_COPY_ON_PROTECTED is ignored by linker
Product: binutils
Version: 2.30 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
When GNU_PROPERTY_NO_COPY_ON_PROTECTED is set on a shared object,
linker shouldn't generate copy relocation on protected symbol defined
in such shared object:
[hjl@gnu-6 protected-3]$ cat foo.c
__attribute__ ((visibility ("protected")))
int protected = 1;
int
get_protected ()
{
return protected;
}
int *
get_protected_p ()
{
return &protected;
}
[hjl@gnu-6 protected-3]$ cat shared.S
.section ".note.gnu.property", "a"
.p2align 3
.long 1f - 0f /* name length. */
.long 3f - 2f /* data length. */
/* NT_GNU_PROPERTY_TYPE_0 */
.long 5 /* note type. */
0: .asciz "GNU" /* vendor name. */
1:
.p2align 3
2:
/* GNU_PROPERTY_NO_COPY_ON_PROTECTED */
.long 2 /* pr_type. */
.long 0 /* pr_datasz. */
.p2align 3
3:
[hjl@gnu-6 protected-3]$ cat main.c
#include <stdlib.h>
extern int protected;
extern int get_protected (void);
extern int* get_protected_p (void);
int main()
{
if (protected != get_protected ())
abort ();
if (&protected != get_protected_p ())
abort ();
return 0;
}
[hjl@gnu-6 protected-3]$ make
gcc -B./ -O -c main.c
gcc -B./ -c -o shared.o shared.S
gcc -B./ -O -fPIE -c foo.c
./ld -shared -o libfoo.so shared.o foo.o
gcc -B./ -o foo main.o libfoo.so -Wl,-rpath,.
for f in foo; do echo "Running: $f"; ./$f; \
if [ $? != 0 ]; then echo Failed; fi; done
Running: foo
/bin/sh: line 1: 28249 Aborted ./$f
Failed
[hjl@gnu-6 protected-3]$
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils