/* simple.c -- BFD simple client routines
- Copyright 2002, 2003, 2004, 2005, 2007
+ Copyright 2002, 2003, 2004, 2005, 2007, 2008
Free Software Foundation, Inc.
Contributed by MontaVista Software, Inc.
int storage_needed;
void *saved_offsets;
- if (! (sec->flags & SEC_RELOC))
+ /* Don't apply relocation on executable and shared library. See
+ PR 4756. */
+ if ((abfd->flags & (HAS_RELOC | EXEC_P | DYNAMIC)) != HAS_RELOC
+ || ! (sec->flags & SEC_RELOC))
{
bfd_size_type amt = sec->rawsize > sec->size ? sec->rawsize : sec->size;
bfd_size_type size = sec->rawsize ? sec->rawsize : sec->size;
/* Fill in the bare minimum number of fields for our purposes. */
memset (&link_info, 0, sizeof (link_info));
+ link_info.output_bfd = abfd;
link_info.input_bfds = abfd;
link_info.input_bfds_tail = &abfd->link_next;
data = NULL;
if (outbuf == NULL)
{
- data = bfd_malloc (sec->size);
+ bfd_size_type amt = sec->rawsize > sec->size ? sec->rawsize : sec->size;
+ data = bfd_malloc (amt);
if (data == NULL)
return NULL;
outbuf = data;