Subject: bin/12865: .init/.fini section handling incorrect.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <skrll@netbsd.org>
List: netbsd-bugs
Date: 05/08/2001 12:33:59
>Number:         12865
>Category:       bin
>Synopsis:       .init/.fini section handling incorrect.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 08 04:34:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Nick Hudson
>Release:        All ELF releases
>Organization:
	I wish...

>Environment:
System: NetBSD kenny 1.5.1_BETA NetBSD 1.5.1_BETA (KENNY) #0: Sat May 5 10:03:38 BST 2001 nick@kenny:/dsk/NetBSD/NetBSD-1.5/src/sys/arch/i386/compile/KENNY i386


>Description:
	.init/.fini section handling is broken on all ELF platforms.

	ld.so should arrange for code in .init/.fini sections to be called
	as if it were part of _init()/_fini() functions.
>How-To-Repeat:
	Build crt{begin,end} from gcc distribution sources. Try to use and see
	failures due to not returning from .init/.fini code.

	Look at the .init/.fini sections:

	$ objdump --disassemble-all --reloc --section=.init crtbegin.o
 
	crtbegin.o:     file format elf32-i386
 
	Disassembly of section .init:
 
	00000000 <.init>:
   	0:   e8 54 00 00 00  call   59 <frame_dummy+0x1>
                        	1: R_386_PC32   .text

	$ objdump --disassemble-all --reloc --section=.fini crtbegin.o
 
	crtbegin.o:     file format elf32-i386
 
	Disassembly of section .fini:
 
	00000000 <.fini>:
   	0:   e8 fc ff ff ff  call   1 <.fini+0x1>
                        	1: R_386_PC32   .text
>Fix:
	Could linker scripts be used?
>Release-Note:
>Audit-Trail:
>Unformatted: