- Instead of looking for and stopping at the first SHT_SYMTAB section, iterate over all SHT_SYMTAB and SHT_DYNSYM sections until we've either found all our symbols or run out.
- Perform bounds checks on section and string table offsets and sizes before attempting to mmap() the string table.
- Perform bounds checks on individual symbol table entries before attempting to access the corresponding strings.
- Stop treating _Foo and Foo as the same symbol.
This unbreaks OpenSSH which uses nlist(3) to verify PKCS#11 providers.
PR: 295336
MFC after: 1 week
Fixes: 77909f597881 ("Initial elf nlist support [...]")
Fixes: 644b4646c7ac ("OpenSSH: Update to 10.1p1")