This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: Warning relocs against discarded functions
- To: "H . J . Lu" <hjl at lucon dot org>
- Subject: Re: PATCH: Warning relocs against discarded functions
- From: Keith Owens <kaos at melbourne dot sgi dot com>
- Date: Fri, 02 Nov 2001 11:43:34 +1100
- Cc: Daniel Jacobowitz <dan at debian dot org>, gdb at sources dot redhat dot com, binutils at sourceware dot cygnus dot com
On Thu, 1 Nov 2001 14:28:35 -0800,
"H . J . Lu" <hjl@lucon.org> wrote:
>On Thu, Nov 01, 2001 at 11:43:10PM +1100, Keith Owens wrote:
>> The problem is worse than stabs. If a function is marked __exit _and_
>> some code in another section refers to that function then :-
>How about this patch?
No go. I patched ld from cygnus CVS, about 2 hours old.
--- x.c
#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit")))
#define __exit __attribute__ ((unused, __section__(".text.exit")))
static void __exit func(void) {}
static void __exit_call (*func_ref)(void) = func;
void _start(void) { func(); }
# gcc (egcs-2.91.66) -Wall x.c -c -o x.o
# ld-new x.o -o x -T arch/i386/vmlinux.lds
No errors :(.
# objdump -h -r x.o
x.o: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000000a 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 00000000 00000000 00000040 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000040 2**2
ALLOC
3 .note 00000014 00000000 00000000 00000040 2**0
CONTENTS, READONLY
4 .text.exit 00000005 00000000 00000000 00000054 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
5 .exitcall.exit 00000004 00000000 00000000 0000005c 2**2
CONTENTS, ALLOC, LOAD, RELOC, DATA
6 .comment 0000003d 00000000 00000000 00000060 2**0
CONTENTS, READONLY
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000004 R_386_PC32 .text.exit
RELOCATION RECORDS FOR [.exitcall.exit]:
OFFSET TYPE VALUE
00000000 R_386_32 .text.exit
# objdump -hS x
x: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000000a c0100000 c0100000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 c0100010 c0100010 00001010 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 c0102000 c0102000 00002000 2**2
ALLOC
3 .comment 0000003d 00000000 00000000 00002000 2**0
CONTENTS, READONLY
4 .note 00000014 00000000 00000000 0000203d 2**0
CONTENTS, READONLY
Disassembly of section .text:
c0100000 <_start>:
c0100000: 55 push %ebp
c0100001: 89 e5 mov %esp,%ebp
c0100003: e8 f8 ff ef 3f call 0 <_text-0xc0100000> <=== oops!
c0100008: c9 leave
c0100009: c3 ret
Debug print in patched code
r_symndx 6 locsymcount 12 elf_bad_symtab (input_bfd) 0 finfo->sections[r_symndx] 0x80dacd4