diff options
author | Chang S. Bae <chang.seok.bae@intel.com> | 2020-04-21 09:23:39 +0000 |
---|---|---|
committer | Chang S. Bae <chang.seok.bae@intel.com> | 2020-04-22 00:05:56 +0000 |
commit | 74b2731f2cef0f1ec8c0c6e6e3dee9492b851e8c (patch) | |
tree | 5225664762f8db7ab7ca38b4078432f22345845a | |
parent | c52aff4cc8680e404cce1cc2a183b7015f07be08 (diff) | |
download | nasm-74b2731f2cef0f1ec8c0c6e6e3dee9492b851e8c.tar.gz |
outelf: Fix the section index for the debug output
The section information delivered to the debug output has an index of the
section table. The index should be different from the total number of
sections at the moment, the returned value from add_sectname(). So, fix the
value.
Fixes: b2004511ddde ("ELF: handle more than 32,633 sections")
Reported-by: C. Masloch <pushbx@ulukai.org>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392654
Reported-by: <mae.bdf@outlook.com>
Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392661
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
-rw-r--r-- | output/outelf.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/output/outelf.c b/output/outelf.c index 4976b680..18b52d88 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -1108,7 +1108,8 @@ static void elf32_out(int32_t segto, const void *data, /* again some stabs debugging stuff */ sinfo.offset = s->len; - sinfo.section = s->shndx; + /* Adjust to an index of the section table. */ + sinfo.section = s->shndx - 1; sinfo.segto = segto; sinfo.name = s->name; dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); @@ -1312,7 +1313,8 @@ static void elf64_out(int32_t segto, const void *data, /* again some stabs debugging stuff */ sinfo.offset = s->len; - sinfo.section = s->shndx; + /* Adjust to an index of the section table. */ + sinfo.section = s->shndx - 1; sinfo.segto = segto; sinfo.name = s->name; dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); @@ -1592,7 +1594,8 @@ static void elfx32_out(int32_t segto, const void *data, /* again some stabs debugging stuff */ sinfo.offset = s->len; - sinfo.section = s->shndx; + /* Adjust to an index of the section table. */ + sinfo.section = s->shndx - 1; sinfo.segto = segto; sinfo.name = s->name; dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); |