[compiler-rt] [HWASan] Fix symbol indexing (PR #135967)
Stefan Bossbaly via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 08:07:24 PDT 2025
================
@@ -76,19 +82,29 @@ def handle_elf(mv):
# have to extend the parsing code.
if mv[:6] != b'\x7fELF\x02\x01':
return None
+ found_symbols = False
+ bid = None
e_shnum, = struct.unpack_from('<H', buffer=mv, offset=e_shnum_offset)
e_shoff, = struct.unpack_from('<Q', buffer=mv, offset=e_shoff_offset)
for i in range(0, e_shnum):
start = e_shoff + i * Shdr_size
- sh_offset, sh_size = handle_Shdr(mv[start: start + Shdr_size])
- if sh_offset is None:
- continue
- note_hdr = mv[sh_offset: sh_offset + sh_size]
- result = handle_Nhdr(note_hdr, sh_size)
- if result is not None:
- return result
+ sh = mv[start: start + Shdr_size]
+ sh_type = unpack_sh_type(sh)
+
+ if sh_type == SHT_SYMTAB:
----------------
StefanBossbaly wrote:
This was a quick way of telling me if the file was stripped, since when the `strip` command is run it will remove the `SYMTAB` section. This is how the `file` command reports if a ELF is stripped or not [1]. I have added logic that will read each section name to determine if ".debug_info" is present. The new logic does require us reading the shstr section since that is where the strings are stored so it does add a bit of complexity. Let me know what you think.
[1]: https://github.com/file/file/blob/f77a1092e1862c2295a21077c9e28c2614a0eede/src/readelf.c#L1479-L1484
https://github.com/llvm/llvm-project/pull/135967
More information about the llvm-commits
mailing list