From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5171 invoked by alias); 27 Feb 2015 23:21:08 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5136 invoked by uid 48); 27 Feb 2015 23:21:05 -0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol Date: Sat, 28 Feb 2015 09:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg03142.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 Bug ID: 65248 Summary: [5 Regression] Copy relocation in PIE against protected symbol Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: tmsriram at google dot com Copy relocation doesn't work with protected symbol and BFD linker enforces it. GCC 5 uses copy relocation in PIE. It either causes linker error or run-time error: [hjl@gnu-6 copyreloc-prot]$ cat x.c extern int a; extern void bar (void); int main() { bar (); if (a != 30) __builtin_abort(); return 0; } [hjl@gnu-6 copyreloc-prot]$ cat bar.c int a; __attribute__((visibility("protected"))) int a; void bar () { a = 30; } [hjl@gnu-6 copyreloc-prot]$ make /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -fpie -c -o x.o x.c /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -fpic -c -o bar.o bar.c /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -shared -o libbar.so bar.o /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -o x x.o libbar.so -Wl,-R,. /usr/local/bin/ld: copy reloc against protected `a' is invalid /usr/local/bin/ld: failed to set dynamic section sizes: Bad value collect2: error: ld returned 1 exit status make: *** [x] Error 1 [hjl@gnu-6 copyreloc-prot]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -o x x.o libbar.so -Wl,-R,. -fuse-ld=gold [hjl@gnu-6 copyreloc-prot]$ ./x Aborted [hjl@gnu-6 copyreloc-prot]$