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: b2004511dd ("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>
This commit is contained in:
Chang S. Bae 2020-04-21 09:23:39 +00:00
parent c52aff4cc8
commit 74b2731f2c

View File

@ -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);