[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/21997] New: GNU_PROPERTY_NO_COPY_ON_PROTECTED is ignored by link
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/21997] New: GNU_PROPERTY_NO_COPY_ON_PROTECTED is ignored by linker |
Date: |
Wed, 23 Aug 2017 19:04:36 +0000 |
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:
address@hidden protected-3]$ cat foo.c
__attribute__ ((visibility ("protected")))
int protected = 1;
int
get_protected ()
{
return protected;
}
int *
get_protected_p ()
{
return &protected;
}
address@hidden 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:
address@hidden 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;
}
address@hidden 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
address@hidden protected-3]$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/21997] New: GNU_PROPERTY_NO_COPY_ON_PROTECTED is ignored by linker,
hjl.tools at gmail dot com <=