This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] SEGV whilst placing sections
- From: Mark Shinwell <shinwell at codesourcery dot com>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: binutils at sourceware dot org, amodra at bigpond dot net dot au
- Date: Wed, 21 Jun 2006 08:23:18 +0100
- Subject: Re: [PATCH] SEGV whilst placing sections
- References: <44980174.6020000@codesourcery.com> <20060620144602.GA4058@lucon.org>
H. J. Lu wrote:
On Tue, Jun 20, 2006 at 03:08:52PM +0100, Mark Shinwell wrote:
The following C code, when compiled for an ARM target with -fexceptions
and linked using the attached linker script, causes SEGV in
lang_insert_orphan () when placing the .ARM.extab section.
int f(int *);
int g(void)
{
int a;
return f(&a);
}
In this case, the "after" parameter to lang_insert_orphan () corresponds
to the .rodata section, the last in the linked list of "asection"s.
The upshot is that place->section points at the "next" entry of the final
section in the list, .rodata. This "next" pointer is NULL, so "as" ends up
NULL, and we fault when "as->prev" is computed.
Can you provide a testcase in assembly so that people can check it
with a cross binutils?
Attached is the output of compiling the above with -fexceptions.
Now the following link should segfault (linker script attached to previous
mail):
arm-none-linux-gnueabi-as -o nonleaf.o nonleaf.s
arm-none-linux-gnueabi-ld -T vmlinux.lds -o nonleaf nonleaf.o
Alan, is this test case ok for you?
Mark
.cpu arm10tdmi
.fpu softvfp
.eabi_attribute 18, 4
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 6
.file "nonleaf.c"
.text
.align 2
.global g
.type g, %function
g:
.fnstart
.LFB2:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
.movsp ip
mov ip, sp
.LCFI0:
stmfd sp!, {fp, ip, lr, pc}
.pad #4
.save {fp, ip, lr}
.LCFI1:
.setfp fp, ip, #-4
sub fp, ip, #4
.LCFI2:
.pad #8
sub sp, sp, #8
.LCFI3:
sub r3, fp, #16
mov r0, r3
bl f
mov r3, r0
mov r0, r3
sub sp, fp, #12
ldmfd sp, {fp, sp, pc}
.LFE2:
.fnend
.size g, .-g
.ident "GCC: (GNU) 4.1.0 (CodeSourcery ARM 2006q1-6)"