PR 9923
[deliverable/binutils-gdb.git] / bfd / simple.c
index 452486834ab93c5ed786a8f6c11900a5a18612db..dd69f9a55964670b8a62e2487c27676f871c9679 100644 (file)
@@ -1,5 +1,5 @@
 /* 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.
 
@@ -162,7 +162,10 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
   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;
@@ -183,6 +186,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
 
   /* 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;
 
This page took 0.023799 seconds and 4 git commands to generate.