Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149515390
D17596.id49252.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D17596.id49252.diff
View Options
Index: contrib/elftoolchain/elfcopy/sections.c
===================================================================
--- contrib/elftoolchain/elfcopy/sections.c
+++ contrib/elftoolchain/elfcopy/sections.c
@@ -697,17 +697,7 @@
elf_errmsg(-1));
/* We don't want to touch relocation info for dynamic symbols. */
- if ((ecp->flags & SYMTAB_EXIST) == 0) {
- if (ish.sh_link == 0 || ecp->secndx[ish.sh_link] == 0) {
- /*
- * This reloc section applies to the symbol table
- * that was stripped, so discard whole section.
- */
- s->nocopy = 1;
- s->sz = 0;
- }
- return;
- } else {
+ if ((ecp->flags & SYMTAB_EXIST) != 0) {
/* Symbol table exist, check if index equals. */
if (ish.sh_link != elf_ndxscn(ecp->symtab->is))
return;
@@ -754,22 +744,38 @@
elf_errmsg(-1));
sym = GELF_R_SYM(rela.r_info);
}
- name = elf_strptr(ecp->ein, elf_ndxscn(ecp->strtab->is), sym);
- if (name == NULL)
- errx(EXIT_FAILURE, "elf_strptr failed: %s",
- elf_errmsg(-1));
- if (lookup_symop_list(ecp, name, SYMOP_KEEP) != NULL) {
- if (ecp->oec == ELFCLASS32) {
- if (s->type == SHT_REL)
- COPYREL(rel, 32);
- else
- COPYREL(rela, 32);
- } else {
- if (s->type == SHT_REL)
- COPYREL(rel, 64);
- else
- COPYREL(rela, 64);
- }
+ /*
+ * If a relocation references a symbol and we are omitting
+ * either that symbol or the entire symbol table we cannot
+ * produce valid output, and so just omit the relocation.
+ * Broken output like this is generally not useful, but some
+ * uses of elfcopy/strip rely on it - for example, GCC's build
+ * process uses it to check for build reproducibility by
+ * stripping objects and comparing them.
+ *
+ * Relocations that do not reference a symbol are retained.
+ */
+ if (sym != 0) {
+ if (ish.sh_link == 0 || ecp->secndx[ish.sh_link] == 0)
+ continue;
+ name = elf_strptr(ecp->ein, elf_ndxscn(ecp->strtab->is),
+ sym);
+ if (name == NULL)
+ errx(EXIT_FAILURE, "elf_strptr failed: %s",
+ elf_errmsg(-1));
+ if (lookup_symop_list(ecp, name, SYMOP_KEEP) == NULL)
+ continue;
+ }
+ if (ecp->oec == ELFCLASS32) {
+ if (s->type == SHT_REL)
+ COPYREL(rel, 32);
+ else
+ COPYREL(rela, 32);
+ } else {
+ if (s->type == SHT_REL)
+ COPYREL(rel, 64);
+ else
+ COPYREL(rela, 64);
}
}
elferr = elf_errno();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 25, 11:43 PM (5 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30352447
Default Alt Text
D17596.id49252.diff (2 KB)
Attached To
Mode
D17596: objcopy: restore behaviour required by GCC's build
Attached
Detach File
Event Timeline
Log In to Comment