Bug 17935 - -z text should provide more info
Summary: -z text should provide more info
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-06 18:25 UTC by H.J. Lu
Modified: 2015-02-07 13:33 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-02-06 18:25:10 UTC
ld should provide more info to help user identify the issue:

[hjl@gnu-6 textrel-2]$ cat foo.s
	.text
	.globl	foo
	.type	foo, @function
foo:
	ret
	.size	foo, .-foo
	.text
	.globl	_start
	.type	_start, @function
_start:
	.size	_start, .-_start
	.text
	.globl	bar
	.type	bar, @function
bar:
	movl	foo, %eax
	.size	bar, .-bar
[hjl@gnu-6 textrel-2]$ make
gcc -m32 -c  -o foo.o foo.s
./ld -m elf_i386 -z text -shared -o libfoo.so foo.o
./ld: read-only segment has dynamic relocations.
make: *** [libfoo.so] Error 1
[hjl@gnu-6 textrel-2]$
Comment 1 H.J. Lu 2015-02-06 20:53:26 UTC
Shouldn't -z text turn on --warn-shared-textrel or at least
inform user to turn on --warn-shared-textrel to get more info?
Comment 2 H.J. Lu 2015-02-06 21:25:00 UTC
-warn-shared-textrel warning is only implemented in elf32-i386.c
and elf64-x86-64.c.
Comment 3 cvs-commit@gcc.gnu.org 2015-02-07 13:31:39 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1952c5cd7d3d24b9647b396731bc4808a2d63d9c

commit 1952c5cd7d3d24b9647b396731bc4808a2d63d9c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Feb 7 05:28:06 2015 -0800

    Issue relocation in RO section warning for -z text
    
    This patch changes linker to issue a warning for relocation in readonly
    section for -z text.
    
    bfd/
    
    	PR ld/17935
    	* elf32-i386.c (elf_i386_readonly_dynrelocs): Also issue a
    	warning for relocation in readonly section for -z text.
    	(elf_i386_size_dynamic_sections): Likewise.
    	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
    	(elf_x86_64_size_dynamic_sections): Likewise.
    
    ld/testsuite/
    
    	PR ld/17935
    	* ld-i386/i386.exp: Run pr17935-1 and pr17935-2.
    	* ld-x86-64/x86-64.exp: Likewise.
    
    	* ld-i386/pr17935-1.d: New file.
    	* ld-i386/pr17935-1.s: Likewise.
    	* ld-i386/pr17935-2.d: Likewise.
    	* ld-i386/pr17935-2.s: Likewise.
    	* ld-x86-64/pr17935-1.d: Likewise.
    	* ld-x86-64/pr17935-1.s: Likewise.
    	* ld-x86-64/pr17935-2.d: Likewise.
    	* ld-x86-64/pr17935-2.s: Likewise.
Comment 4 H.J. Lu 2015-02-07 13:33:00 UTC
Fixed for 2.26.