This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: segfault in bfd with large static binary
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: binutils at sourceware dot org
- Date: Wed, 1 Feb 2006 10:39:08 -0800
- Subject: PATCH: segfault in bfd with large static binary
- References: <200601312314.51054.vapier@gentoo.org>
On Tue, Jan 31, 2006 at 11:14:51PM -0500, Mike Frysinger wrote:
> i was building statically the latest busybox binary on amd64 and when i went
> to strip it, strip segfaulted on me
>
> normally i use binutils 2.16.1, but i found 2.16.91.0.5 and the 060131
> snapshot bombed out the same way
>
> i'd attach the binary but it's about 2megs :)
> http://dev.gentoo.org/~vapier/busybox
>
> i got others to verify various Gentoo systems, but i dont have any
> Debian/Fedora amd64 chroots around so can someone else check to make sure
> this isnt just a screw up on my end ? just running `strip busybox` would
> segfault in libbfd.so _bfd_elf_compute_section_file_positions() ...
> -mike
elf.c has
#define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
((((segment->p_paddr \
? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
: IS_CONTAINED_BY_VMA (section, segment)) \
p_paddr is unspecified for ELF. Why do we bother to check it? This
patch fixes the crash.
BYW, I don't quite understand why we have IS_CONTAINED_BY_LMA at all.
But I am afraid to remove it.
H.J.
----
2006-02-01 H.J. Lu <hongjiu.lu@intel.com>
* elf.c (INCLUDE_SECTION_IN_SEGMENT): Don't check lma.
--- bfd/elf.c.vma 2006-01-20 08:53:55.000000000 -0800
+++ bfd/elf.c 2006-02-01 10:30:35.000000000 -0800
@@ -5129,8 +5129,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *o
/* Decide if the given section should be included in the given segment.
A section will be included if:
- 1. It is within the address space of the segment -- we use the LMA
- if that is set for the segment and the VMA otherwise,
+ 1. It is within the address space of the segment.
2. It is an allocated segment,
3. There is an output section associated with it,
4. The section has not already been allocated to a previous segment.
@@ -5140,9 +5139,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *o
8. PT_DYNAMIC should not contain empty sections at the beginning
(with the possible exception of .dynamic). */
#define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
- ((((segment->p_paddr \
- ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
- : IS_CONTAINED_BY_VMA (section, segment)) \
+ (((IS_CONTAINED_BY_VMA (section, segment) \
&& (section->flags & SEC_ALLOC) != 0) \
|| IS_COREFILE_NOTE (segment, section)) \
&& section->output_section != NULL \