Subject: bin/8547: arm-32 ld: Misuse of alloca
To: None <gnats-bugs@gnats.netbsd.org>
From: Richard Earnshaw <rearnsha@cambridge.arm.com>
List: netbsd-bugs
Date: 10/04/1999 04:25:00
>Number: 8547
>Category: bin
>Synopsis: arm-32 ld: Misuse of alloca
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 4 04:20:01 1999
>Last-Modified:
>Originator: Richard Earnshaw
>Organization:
ARM
--
>Release: -current
>Environment:
System: NetBSD shark1 1.4K NetBSD 1.4K (SHARK) #46: Thu Sep 30 18:19:47 BST 1999 rearnsha@shark1:/usr/src/sys/arch/arm32/compile/SHARK arm32
>Description:
ld uses alloca for termporary allocation of space for the string
section of objects it is linking. This can easily ammount to more
space than is permitted by the kernel for the stack segment when
linking large programs.
>How-To-Repeat:
Try to build a debug version of mozilla for arm-32 on a SHARK.
Be a bit confused as to why a store-multiple to the stack is being
faulted when the stack-pointer looks valid, then discover that the
stack has exceeded the kernel's hard limits (currently 8 Mbytes).
>Fix:
Well, you could build a kernel with a very large stack, but the
following patch to ld is probably a better long-term bet.
Index: lib.c
===================================================================
RCS file: /home/rearnsha/netbsd/cvs/src/gnu/usr.bin/ld/ld/lib.c,v
retrieving revision 1.1.1.3
diff -p -r1.1.1.3 lib.c
*** lib.c 1999/01/08 21:45:37 1.1.1.3
--- lib.c 1999/10/02 17:42:33
*************** symdef_library(fd, entry, member_length)
*** 306,312 ****
read_entry_symbols(fd, subentry);
subentry->strings = (char *)
! alloca(subentry->string_size);
read_entry_strings(fd, subentry);
/*
--- 306,312 ----
read_entry_symbols(fd, subentry);
subentry->strings = (char *)
! malloc(subentry->string_size);
read_entry_strings(fd, subentry);
/*
*************** symdef_library(fd, entry, member_length)
*** 319,324 ****
--- 319,325 ----
if (subentry->symbols)
free(subentry->symbols);
free(subentry->filename);
+ free(subentry->strings);
free(subentry);
} else {
/*
*************** symdef_library(fd, entry, member_length)
*** 354,359 ****
--- 355,361 ----
* We'll read the strings again
* if we need them.
*/
+ free(subentry->strings);
subentry->strings = 0;
}
}
>Audit-Trail:
>Unformatted: