In the link_elf_obj.c, handle sections of type SHT_AMD64_UNWIND same

as SHT_PROGBITS.  This is needed after the clang 3.8 import, which
generates that type for .eh_frame section, which had SHT_PROGBITS type
before.

Reported by:	 Nikolai Lifanov <lifanov@mail.lifanov.com>
PR:	207729
Tested by:	dim (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
This commit is contained in:
Konstantin Belousov 2016-03-06 00:31:11 +00:00
parent 1dcfcfee2a
commit 13f28d969a

View File

@ -257,6 +257,9 @@ link_elf_link_preload(linker_class_t cls, const char *filename,
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
#ifdef __amd64__
case SHT_AMD64_UNWIND:
#endif
ef->nprogtab++;
break;
case SHT_SYMTAB:
@ -327,9 +330,16 @@ link_elf_link_preload(linker_class_t cls, const char *filename,
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
#ifdef __amd64__
case SHT_AMD64_UNWIND:
#endif
ef->progtab[pb].addr = (void *)shdr[i].sh_addr;
if (shdr[i].sh_type == SHT_PROGBITS)
ef->progtab[pb].name = "<<PROGBITS>>";
#ifdef __amd64__
else if (shdr[i].sh_type == SHT_AMD64_UNWIND)
ef->progtab[pb].name = "<<UNWIND>>";
#endif
else
ef->progtab[pb].name = "<<NOBITS>>";
ef->progtab[pb].size = shdr[i].sh_size;
@ -575,6 +585,9 @@ link_elf_load_file(linker_class_t cls, const char *filename,
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
#ifdef __amd64__
case SHT_AMD64_UNWIND:
#endif
ef->nprogtab++;
break;
case SHT_SYMTAB:
@ -681,6 +694,9 @@ link_elf_load_file(linker_class_t cls, const char *filename,
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
#ifdef __amd64__
case SHT_AMD64_UNWIND:
#endif
alignmask = shdr[i].sh_addralign - 1;
mapsize += alignmask;
mapsize &= ~alignmask;
@ -748,6 +764,9 @@ link_elf_load_file(linker_class_t cls, const char *filename,
switch (shdr[i].sh_type) {
case SHT_PROGBITS:
case SHT_NOBITS:
#ifdef __amd64__
case SHT_AMD64_UNWIND:
#endif
alignmask = shdr[i].sh_addralign - 1;
mapbase += alignmask;
mapbase &= ~alignmask;
@ -760,6 +779,10 @@ link_elf_load_file(linker_class_t cls, const char *filename,
}
} else if (shdr[i].sh_type == SHT_PROGBITS)
ef->progtab[pb].name = "<<PROGBITS>>";
#ifdef __amd64__
else if (shdr[i].sh_type == SHT_AMD64_UNWIND)
ef->progtab[pb].name = "<<UNWIND>>";
#endif
else
ef->progtab[pb].name = "<<NOBITS>>";
if (ef->progtab[pb].name != NULL &&
@ -781,7 +804,11 @@ link_elf_load_file(linker_class_t cls, const char *filename,
}
ef->progtab[pb].size = shdr[i].sh_size;
ef->progtab[pb].sec = i;
if (shdr[i].sh_type == SHT_PROGBITS) {
if (shdr[i].sh_type == SHT_PROGBITS
#ifdef __amd64__
|| shdr[i].sh_type == SHT_AMD64_UNWIND
#endif
) {
error = vn_rdwr(UIO_READ, nd.ni_vp,
ef->progtab[pb].addr,
shdr[i].sh_size, shdr[i].sh_offset,