diff options
author | Alan Modra <amodra@gmail.com> | 2020-05-04 10:20:54 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-05-04 11:28:40 +0930 |
commit | 9c7b8e9b92696f38ff29efeeb12eb166994c0a23 (patch) | |
tree | b213f04eac47577b58a4e28dc4b716ed4cc2223b | |
parent | c3bf7d31de6b0c693c1c873ce3c36bc8c43ca06a (diff) | |
download | gdb-9c7b8e9b92696f38ff29efeeb12eb166994c0a23.zip gdb-9c7b8e9b92696f38ff29efeeb12eb166994c0a23.tar.gz gdb-9c7b8e9b92696f38ff29efeeb12eb166994c0a23.tar.bz2 |
readelf: nds32 specific decoding
* readelf.c (process_nds32_specific): Check size of .nds32_e_flags
section. Don't assume endian of host matches nds32 target. Free
buffer.
-rw-r--r-- | binutils/ChangeLog | 6 | ||||
-rw-r--r-- | binutils/readelf.c | 15 |
2 files changed, 15 insertions, 6 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 52082fc..7b0d1a0 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2020-05-04 Alan Modra <amodra@gmail.com> + + * readelf.c (process_nds32_specific): Check size of .nds32_e_flags + section. Don't assume endian of host matches nds32 target. Free + buffer. + 2020-05-01 Alan Modra <amodra@gmail.com> Haim Shimonovich <Haim.Shimonovich@ceva-dsp.com> diff --git a/binutils/readelf.c b/binutils/readelf.c index 4ceb6b2..25c2cce 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -17481,18 +17481,21 @@ process_nds32_specific (Filedata * filedata) Elf_Internal_Shdr *sect = NULL; sect = find_section (filedata, ".nds32_e_flags"); - if (sect != NULL) + if (sect != NULL && sect->sh_size >= 4) { - unsigned int *flag; + unsigned char *buf; + unsigned int flag; printf ("\nNDS32 elf flags section:\n"); - flag = get_data (NULL, filedata, sect->sh_offset, 1, - sect->sh_size, _("NDS32 elf flags section")); + buf = get_data (NULL, filedata, sect->sh_offset, 1, 4, + _("NDS32 elf flags section")); - if (! flag) + if (buf == NULL) return FALSE; - switch ((*flag) & 0x3) + flag = byte_get (buf, 4); + free (buf); + switch (flag & 0x3) { case 0: printf ("(VEC_SIZE):\tNo entry.\n"); |