On Tue, 7 Apr 2015, Martijn van Duren wrote:
> $ nm -e ./a.out
...
> W __cxa_atexit -> _dl_searchnum
...
> 00000c90 W __register_frame_info -> (null)
...
> 00000dd4 W pthread_create -> __got_end
> 00000dfd W pthread_mutex_init -> __data_start
> 00000e10 W pthread_mutex_lock -> exit
> 00000e1f W pthread_mutex_unlock -> atexit
The output from nm -e is just bogus here; weak symbols are *not* like old
a.out indirections and don't resolve like that.
Since ELF doesn't have the "resolve symbol X by resolving symbol Y"
behavior at all (not even the GNU "IFUNC" symbol type is quite like that),
let's remove the old N_INDR code from nm. The first chunk is the
important one; the rest is just cleanup.
Side note: with this, the only effect of the -e option is to add more
whitespace...
ok?
Philip Guenther
Index: elf.c
===================================================================
RCS file: /cvs/src/usr.bin/nm/elf.c,v
retrieving revision 1.26
diff -u -p -r1.26 elf.c
--- elf.c 6 Feb 2015 23:21:59 -0000 1.26
+++ elf.c 8 Apr 2015 05:21:22 -0000
@@ -376,7 +376,6 @@ elf2nlist(Elf_Sym *sym, Elf_Ehdr *eh, El
type = elf_shn2type(eh, sym->st_shndx, NULL);
np->n_type = type < 0? N_TEXT : type;
if (ELF_ST_BIND(sym->st_info) == STB_WEAK) {
- np->n_type = N_INDR;
np->n_other = 'W';
} else if (sn != NULL && *sn != 0 &&
strcmp(sn, ELF_INIT) &&
Index: nm.c
===================================================================
RCS file: /cvs/src/usr.bin/nm/nm.c,v
retrieving revision 1.43
diff -u -p -r1.43 nm.c
--- nm.c 8 Apr 2015 04:23:15 -0000 1.43
+++ nm.c 8 Apr 2015 05:21:22 -0000
@@ -710,12 +710,8 @@ show_file(int count, int warn_fmt, const
(void)printf("\n%s:\n", name);
/* print out symbols */
- for (i = 0; i < nnames; i++) {
- if (show_extensions && snames[i] != names &&
- SYMBOL_TYPE((snames[i] -1)->n_type) == N_INDR)
- continue;
+ for (i = 0; i < nnames; i++)
print_symbol(name, snames[i]);
- }
free(snames);
free(names);
@@ -745,9 +741,7 @@ print_symbol(const char *name, struct nl
*/
if (!print_only_undefined_symbols) {
/* print symbol's value */
- if (SYMBOL_TYPE(sym->n_type) == N_UNDF ||
- (show_extensions && SYMBOL_TYPE(sym->n_type) == N_INDR &&
- sym->n_value == 0))
+ if (SYMBOL_TYPE(sym->n_type) == N_UNDF)
(void)printf(" ");
else
(void)printf("%08lx", sym->n_value);
@@ -759,10 +753,7 @@ print_symbol(const char *name, struct nl
(void)printf(" %c ", typeletter(sym));
}
- if (SYMBOL_TYPE(sym->n_type) == N_INDR && show_extensions)
- printf("%s -> %s\n", symname(sym), symname(sym+1));
- else
- (void)puts(symname(sym));
+ (void)puts(symname(sym));
}
/*
@@ -796,8 +787,6 @@ typeletter(struct nlist *np)
return(ext? 'F' : 'W');
case N_TEXT:
return(ext? 'T' : 't');
- case N_INDR:
- return(ext? 'I' : 'i');
case N_SIZE:
return(ext? 'S' : 's');
case N_UNDF: