This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: ld/2462: -Wl,-s always output unused bytes at the end
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Cc: paul at codesourcery dot com
- Date: Fri, 17 Mar 2006 06:02:52 -0800
- Subject: PATCH: ld/2462: -Wl,-s always output unused bytes at the end
This is a regression caused by
http://sourceware.org/ml/binutils/2005-05/msg00170.html
If Paul has no problems with vxworks, I'd like to check it as an
obvious fix.
Thanks.
H.J.
----
2006-03-17 H.J. Lu <hongjiu.lu@intel.com>
PR ld/2462
* elflink.c (elf_emit_relocs): New.
(elf_link_input_bfd): Emit relocations only when needed. Call
elf_emit_relocs instead of bed->elf_backend_emit_relocs.
* elfxx-target.h (elf_backend_emit_relocs): Default to NULL.
--- bfd/elflink.c.reloc 2006-03-16 21:44:49.000000000 -0800
+++ bfd/elflink.c 2006-03-17 05:51:31.000000000 -0800
@@ -6809,6 +6809,29 @@ _bfd_elf_check_kept_section (asection *s
return kept;
}
+static bfd_boolean
+elf_emit_relocs (struct elf_final_link_info *finfo,
+ bfd *output_bfd,
+ asection *input_section,
+ Elf_Internal_Shdr *input_rel_hdr,
+ Elf_Internal_Rela *internal_relocs,
+ struct elf_link_hash_entry **rel_hash)
+{
+ const struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (output_bfd);
+ if (bed->elf_backend_emit_relocs)
+ return bed->elf_backend_emit_relocs (output_bfd, input_section,
+ input_rel_hdr,
+ internal_relocs, rel_hash);
+ else if (finfo->info->relocatable || finfo->info->emitrelocations)
+ return _bfd_elf_link_output_relocs (output_bfd, input_section,
+ input_rel_hdr, internal_relocs,
+ rel_hash);
+ else
+ return TRUE;
+}
+
/* Link an input file into the linker output file. This function
handles all the sections and relocations of the input file at once.
This is so that we only have to read the local symbols once, and
@@ -6845,7 +6868,8 @@ elf_link_input_bfd (struct elf_final_lin
return TRUE;
emit_relocs = (finfo->info->relocatable
- || finfo->info->emitrelocations);
+ || finfo->info->emitrelocations
+ || bed->elf_backend_emit_relocs);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
if (elf_bad_symtab (input_bfd))
@@ -7416,10 +7440,9 @@ elf_link_input_bfd (struct elf_final_lin
/* Swap out the relocs. */
if (input_rel_hdr->sh_size != 0
- && !bed->elf_backend_emit_relocs (output_bfd, o,
- input_rel_hdr,
- internal_relocs,
- rel_hash_list))
+ && !elf_emit_relocs (finfo, output_bfd, o,
+ input_rel_hdr, internal_relocs,
+ rel_hash_list))
return FALSE;
input_rel_hdr2 = elf_section_data (o)->rel_hdr2;
@@ -7428,10 +7451,10 @@ elf_link_input_bfd (struct elf_final_lin
internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr)
* bed->s->int_rels_per_ext_rel);
rel_hash_list += NUM_SHDR_ENTRIES (input_rel_hdr);
- if (!bed->elf_backend_emit_relocs (output_bfd, o,
- input_rel_hdr2,
- internal_relocs,
- rel_hash_list))
+ if (!elf_emit_relocs (finfo, output_bfd, o,
+ input_rel_hdr2,
+ internal_relocs,
+ rel_hash_list))
return FALSE;
}
}
--- bfd/elfxx-target.h.reloc 2006-02-27 15:50:54.000000000 -0800
+++ bfd/elfxx-target.h 2006-03-17 05:27:36.000000000 -0800
@@ -430,7 +430,7 @@
#define elf_backend_ignore_undef_symbol NULL
#endif
#ifndef elf_backend_emit_relocs
-#define elf_backend_emit_relocs _bfd_elf_link_output_relocs
+#define elf_backend_emit_relocs NULL
#endif
#ifndef elf_backend_count_relocs
#define elf_backend_count_relocs NULL