diff options
author | Timm Bäder <tbaeder@redhat.com> | 2021-02-17 09:43:46 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-03-01 18:07:10 +0100 |
commit | 39c67b8f6c0dcee999eb8e73f8e07a41efb78c2b (patch) | |
tree | 942abcf7e85b89f23f11afead1b68b1cb5353977 | |
parent | 2daab4e7661eee6fe8701800a8e54d2448471cbd (diff) | |
download | elfutils-39c67b8f6c0dcee999eb8e73f8e07a41efb78c2b.tar.gz |
unstrip: Inline find_unalloc_section() into only caller
Get rid of an unnecessary nested function this way.
Signed-off-by: Timm Bäder <tbaeder@redhat.com>
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/unstrip.c | 47 |
2 files changed, 27 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9e7d6cb9..f358baa2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2021-02-17 Timm Bäder <tbaeder@redhat.com> + * unstrip.c (copy_elided_sections): Inline find_unalloc_section + function into calling location. The sec pointer is set to NULL + before the if-else statement and only set when match is found. + +2021-02-17 Timm Bäder <tbaeder@redhat.com> + * unstrip.c (find_alloc_sections_prelink): Move check_match to... (check_match): Adjusted to return whether there was no match, which indicates a failure. So callers are adjusted to or the diff --git a/src/unstrip.c b/src/unstrip.c index 72fabac8..90e02831 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -1452,29 +1452,6 @@ more sections in stripped file than debug file -- arguments reversed?")); stripped_symtab = §ions[nalloc]; } - /* Locate a matching unallocated section in SECTIONS. */ - inline struct section *find_unalloc_section (const GElf_Shdr *shdr, - const char *name, - const char *sig) - { - size_t l = nalloc, u = stripped_shnum - 1; - while (l < u) - { - size_t i = (l + u) / 2; - struct section *sec = §ions[i]; - int cmp = compare_unalloc_sections (shdr, &sec->shdr, - name, sec->name, - sig, sec->sig); - if (cmp < 0) - u = i; - else if (cmp > 0) - l = i + 1; - else - return sec; - } - return NULL; - } - Elf_Data *shstrtab = elf_getdata (elf_getscn (unstripped, unstripped_shstrndx), NULL); ELF_CHECK (shstrtab != NULL, @@ -1536,9 +1513,27 @@ more sections in stripped file than debug file -- arguments reversed?")); } else { - /* Look for the section that matches. */ - sec = find_unalloc_section (shdr, name, - get_group_sig (unstripped, shdr)); + /* Locate a matching unallocated section in SECTIONS. */ + const char *sig = get_group_sig (unstripped, shdr); + size_t l = nalloc, u = stripped_shnum - 1; + while (l < u) + { + size_t i = (l + u) / 2; + struct section *section = §ions[i]; + int cmp = compare_unalloc_sections (shdr, §ion->shdr, + name, section->name, + sig, section->sig); + if (cmp < 0) + u = i; + else if (cmp > 0) + l = i + 1; + else + { + sec = section; + break; + } + } + if (sec == NULL) { /* An additional unallocated section is fine if not SHT_NOBITS. |