This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Fix stripping of prelinked binaries and libraries
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 11 Oct 2004 15:38:17 +0200
- Subject: [PATCH] Fix stripping of prelinked binaries and libraries
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Although it is not a good idea to strip prelinked binaries or
libraries (as they are afterwards no longer un-prelinkable), some
people are trying to do that.
And it completely breaks the binaries, as e.g. .gnu.liblist section
is killed, but references to it in .dynamic stay, thus the binaries
segfault on startup.
The following patch attempts to cure this:
2004-10-11 Jakub Jelinek <jakub@redhat.com>
* elf.c (bfd_section_from_shdr): Handle SHT_GNU_LIBLIST.
(special_sections): Add .gnu.liblist and .gnu.conflict.
(assign_section_numbers): Handle SHT_GNU_LIBLIST.
--- bfd/elf.c.jj 2004-10-11 12:50:09.000000000 +0200
+++ bfd/elf.c 2004-10-11 15:00:18.649674588 +0200
@@ -1739,6 +1739,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
case SHT_INIT_ARRAY: /* .init_array section. */
case SHT_FINI_ARRAY: /* .fini_array section. */
case SHT_PREINIT_ARRAY: /* .preinit_array section. */
+ case SHT_GNU_LIBLIST: /* .gnu.liblist section. */
return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
case SHT_DYNAMIC: /* Dynamic linking information. */
@@ -2132,6 +2133,8 @@ static struct bfd_elf_special_section co
{ ".rela", 5, -1, SHT_RELA, 0 },
{ ".rel", 4, -1, SHT_REL, 0 },
{ ".stabstr", 5, 3, SHT_STRTAB, 0 },
+ { ".gnu.liblist", 12, 0, SHT_GNU_LIBLIST, SHF_ALLOC },
+ { ".gnu.conflict", 13, 0, SHT_RELA, SHF_ALLOC },
{ NULL, 0, 0, 0, 0 }
};
@@ -2969,6 +2972,17 @@ assign_section_numbers (bfd *abfd)
d->this_hdr.sh_link = elf_section_data (s)->this_idx;
break;
+ case SHT_GNU_LIBLIST:
+ /* sh_link is the section header index of the prelink library
+ list
+ used for the dynamic entries, or the symbol table, or the
+ version strings. */
+ s = bfd_get_section_by_name (abfd, (sec->flags & SEC_ALLOC)
+ ? ".dynstr" : ".gnu.libstr");
+ if (s != NULL)
+ d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+ break;
+
case SHT_HASH:
case SHT_GNU_versym:
/* sh_link is the section header index of the symbol table
Jakub