[PATCH] D26937: llvm-nm: Print correct symbol types for init and fini sections
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 18:08:45 PDT 2019
MaskRay added a comment.
This copied a bug from GNU nm.
static const struct section_to_type stt[] =
{
{".bss", 'b'},
{"code", 't'}, /* MRI .text */
{".data", 'd'},
{"*DEBUG*", 'N'},
{".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */
{".drectve", 'i'}, /* MSVC's .drective section */
{".edata", 'e'}, /* MSVC's .edata (export) section */
{".fini", 't'}, /* ELF fini section */
{".idata", 'i'}, /* MSVC's .idata (import) section */
{".init", 't'}, /* ELF init section */
{".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */
{".rdata", 'r'}, /* Read only data. */
{".rodata", 'r'}, /* Read only data. */
{".sbss", 's'}, /* Small BSS (uninitialized data). */
{".scommon", 'c'}, /* Small common. */
{".sdata", 'g'}, /* Small initialized data. */
{".text", 't'},
{"vars", 'd'}, /* MRI .data */
{"zerovars", 'b'}, /* MRI .bss */
{0, 0}
};
/* Return the single-character symbol type corresponding to
section S, or '?' for an unknown COFF section.
Check for any leading string which matches, so .text5 returns
't' as well as .text */
static char
coff_section_type (const char *s)
{
const struct section_to_type *t;
for (t = &stt[0]; t->section; t++)
if (!strncmp (s, t->section, strlen (t->section))) ///////// symbols in ".init_array" are incorrectly marked "t"
return t->type;
return '?';
}
The behavior is not consistent with a symbol defined in `.preinit_array`, e.g.
d __preinit_array_start
t __init_array_start
The more sensible choice is probably to mark both as `d`.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D26937/new/
https://reviews.llvm.org/D26937
More information about the llvm-commits
mailing list