diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-08-29 11:28:10 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-08-29 11:28:10 -0700 |
commit | 823cb06774ad6a2aee0afcf6f011c3a134f25747 (patch) | |
tree | b400a7d85bd197f10426377492eafbf4e75432a9 | |
parent | 37c0b6ee65941d54fa8064c21b39f97fdc318156 (diff) | |
download | gdb-823cb06774ad6a2aee0afcf6f011c3a134f25747.zip gdb-823cb06774ad6a2aee0afcf6f011c3a134f25747.tar.gz gdb-823cb06774ad6a2aee0afcf6f011c3a134f25747.tar.bz2 |
x86: Simplify bad return in get_synthetic_symtab
* elf32-i386.c (elf_i386_get_synthetic_symtab): Simplify bad
return.
* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 18 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 18 |
3 files changed, 20 insertions, 22 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 21b01b7..71b96dd 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2017-08-29 H.J. Lu <hongjiu.lu@intel.com> + * elf32-i386.c (elf_i386_get_synthetic_symtab): Simplify bad + return. + * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Likewise. + +2017-08-29 H.J. Lu <hongjiu.lu@intel.com> + * elf32-i386.c (elf_i386_get_synthetic_symtab): Check valid PLT sections before checking dynamic relocations and free invalid PLT section contents. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 31ef02a..2826272 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -6504,14 +6504,7 @@ elf_i386_get_synthetic_symtab (bfd *abfd, s = *ret = (asymbol *) bfd_zmalloc (size); if (s == NULL) - { -bad_return: - for (j = 0; plts[j].name != NULL; j++) - if (plts[j].contents != NULL) - free (plts[j].contents); - free (dynrelbuf); - return -1; - } + goto bad_return; if (got_addr) { @@ -6639,9 +6632,12 @@ bad_return: /* PLT entries with R_386_TLS_DESC relocations are skipped. */ if (n == 0) - goto bad_return; - - count = n; + { +bad_return: + count = -1; + } + else + count = n; for (j = 0; plts[j].name != NULL; j++) if (plts[j].contents != NULL) diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index ba7c595..847a182 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -6896,14 +6896,7 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd, s = *ret = (asymbol *) bfd_zmalloc (size); if (s == NULL) - { -bad_return: - for (j = 0; plts[j].name != NULL; j++) - if (plts[j].contents != NULL) - free (plts[j].contents); - free (dynrelbuf); - return -1; - } + goto bad_return; /* Check for each PLT section. */ names = (char *) (s + count); @@ -7014,9 +7007,12 @@ bad_return: /* PLT entries with R_X86_64_TLSDESC relocations are skipped. */ if (n == 0) - goto bad_return; - - count = n; + { +bad_return: + count = -1; + } + else + count = n; for (j = 0; plts[j].name != NULL; j++) if (plts[j].contents != NULL) |