Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/elftoolchain/elfcopy/sections.c
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | is_remove_reloc_sec(struct elfcopy *ecp, uint32_t sh_info) | ||||
Elf_Scn *is; | Elf_Scn *is; | ||||
size_t indx; | size_t indx; | ||||
int elferr; | int elferr; | ||||
if (elf_getshstrndx(ecp->ein, &indx) == 0) | if (elf_getshstrndx(ecp->ein, &indx) == 0) | ||||
errx(EXIT_FAILURE, "elf_getshstrndx failed: %s", | errx(EXIT_FAILURE, "elf_getshstrndx failed: %s", | ||||
elf_errmsg(-1)); | elf_errmsg(-1)); | ||||
is = NULL; | is = elf_getscn(ecp->ein, sh_info); | ||||
while ((is = elf_nextscn(ecp->ein, is)) != NULL) { | if (is != NULL) { | ||||
if (sh_info == elf_ndxscn(is)) { | |||||
if (gelf_getshdr(is, &ish) == NULL) | if (gelf_getshdr(is, &ish) == NULL) | ||||
errx(EXIT_FAILURE, "gelf_getshdr failed: %s", | errx(EXIT_FAILURE, "gelf_getshdr failed: %s", | ||||
elf_errmsg(-1)); | elf_errmsg(-1)); | ||||
if ((name = elf_strptr(ecp->ein, indx, ish.sh_name)) == | if ((name = elf_strptr(ecp->ein, indx, ish.sh_name)) == | ||||
NULL) | NULL) | ||||
errx(EXIT_FAILURE, "elf_strptr failed: %s", | errx(EXIT_FAILURE, "elf_strptr failed: %s", | ||||
elf_errmsg(-1)); | elf_errmsg(-1)); | ||||
if (is_remove_section(ecp, name)) | if (is_remove_section(ecp, name)) | ||||
return (1); | return (1); | ||||
else | else | ||||
return (0); | return (0); | ||||
} | |||||
} | } | ||||
elferr = elf_errno(); | elferr = elf_errno(); | ||||
if (elferr != 0) | if (elferr != 0) | ||||
errx(EXIT_FAILURE, "elf_nextscn failed: %s", | errx(EXIT_FAILURE, "elf_nextscn failed: %s", | ||||
elf_errmsg(elferr)); | elf_errmsg(elferr)); | ||||
/* Remove reloc section if we can't find the target section. */ | /* Remove reloc section if we can't find the target section. */ | ||||
return (1); | return (1); | ||||
▲ Show 20 Lines • Show All 1,597 Lines • Show Last 20 Lines |