History log of /openbsd-current/usr.bin/nm/nm.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.56 21-May-2024 jsg

remove prototypes with no matching function and externs with no var
partly checked by millert@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.55 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.54 03-Mar-2019 schwarze

on malloc(3) failure, gracefully abort processing of the current file
rather than crashing with a NULL pointer access;
patch from Benjamin Baier <programmer at netzbasis dot de>;
OK otto@ deraadt@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.53 27-Oct-2017 mpi

Use <elf.h> instead of <elf_abi.h>

ok jasper@, jca@, deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.52 12-Sep-2017 mpi

Include room for NUL-termination when calculating the length of archive
member name.

Fix an of by one found by sthen@ with MALLOC_OPTIONS=C.

From Matthew Martin, ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.51 09-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.50 13-Nov-2015 deraadt

ratchet pledge from the start; from Theo Buehler


# 1.49 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.48 05-Oct-2015 deraadt

tame "stdio rpath" works fine, as long as we sidestep the demangling
process which involves fork+execve....
ok doug


# 1.47 13-Aug-2015 miod

Grow -P (POSIX output) and -t (POSIX output radix) support. Several 3rd-party
software depend upon this.

Requested by feinerer@, ok millert@; manpage bits ok jmc@


Revision tags: OPENBSD_5_8_BASE
# 1.46 17-May-2015 guenther

Add 'D' to usage optstring. Prodded by jmc@


# 1.45 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.44 09-Apr-2015 guenther

ELF weak symbols are _not_ like a.out indirect symbols. Nothing in ELF is,
so remove N_INDR handling.

ok kettenis@


# 1.43 08-Apr-2015 guenther

Delete another piece of a.out detritus


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.41 28-Apr-2014 miod

Ignore IRIX6-compatible archive map on mips64 platform, since the mips64
toolchain creates them. This lets nm -w correctly return 0 for valid archives.

ok jasper@ deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.40 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.39 12-Nov-2013 deraadt

avoid math on void * pointers; delete an unused variable


# 1.38 12-Nov-2013 deraadt

remove more code accidentally left behind during the a.out purge


# 1.37 24-Oct-2013 miod

Redo 1.34+1.35, but ignore incorrect files in show_file() as done in 1.33.
Fixes nm output on archives on mips.


# 1.36 24-Oct-2013 deraadt

back out to 1.33, subtle bug being hunted...


# 1.35 21-Oct-2013 deraadt

remove a space that snuck into the output


# 1.34 19-Oct-2013 deraadt

Remove a.out/stab knowledge from nm.
(As a side effect of this repair, the -e option no longer reports that
all weak objects are functions)
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.33 06-Feb-2011 jasper

- nm -s omitted the symbol list for first object file in an archive. fix this
by forcing show_symtab() to restore its original file offset after processing.

fix from pr #6385.
ok miod@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.32 27-Oct-2009 deraadt

nm -V is silly, and prining the rcsid even more so


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.31 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.30 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.29 03-Jan-2005 espie

don't try to demangle C symbols if we're ELF.
looks okay mickey@


# 1.28 10-Oct-2004 mickey

now that no cpu assumptions are left in -- remove the cross-glue


# 1.27 09-Oct-2004 mickey

move out elf code into elf.c and generate 32 and 64 versions of it;
allow operation on size-mixed host-target as well as ensianess for
both a.out and elf (though a.out 64bit probably does not exist ;)
tested on hppa-sparc64-i386-vax intermixen


Revision tags: OPENBSD_3_6_BASE
# 1.26 11-Jul-2004 mickey

need to byteswap string table size before use for the alien endian a.out


# 1.25 04-May-2004 deraadt

spacing


# 1.24 29-Apr-2004 miod

Correctly report empty a.out objects as "no name list" instead of "bad format".

ok mickey@ millert@


Revision tags: OPENBSD_3_5_BASE
# 1.23 14-Jan-2004 millert

Fix the mmap case; inadequate testing on my part!


# 1.22 14-Jan-2004 millert

Fallback to malloc + pread if mmap fails; fixes "nm /dev/ksyms". OK mickey@


# 1.21 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.20 05-Jan-2004 mickey

nm digs elf and merges w/ size; millert@ ok


Revision tags: OPENBSD_3_4_BASE
# 1.19 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.18 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.17 05-Apr-2003 deraadt

snprintf; ok miod ho henning


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.14 17-Aug-2001 espie

Some missing protos. Use macros from <link.h> instead of rolling our own.


# 1.13 17-Aug-2001 espie

Show indirect symbols in -e mode.


# 1.12 16-Aug-2001 espie

-e switch, show extra symbol information such as weak symbol status.


# 1.11 31-May-2001 smart

- remove erealloc() wrapper function
- standard function prototypes
- remove extraneous exit(1) after an err(1,...)

Shrinks source by 11 lines and executable by 22 bytes on i386. deraadt@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.10 18-Feb-2001 espie

-C support.
Recognize -B, for better gnu-nm compatibility.


# 1.9 10-Nov-2000 provos

seperate -> separate, okay aaron@


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 10-May-1999 espie

Fixes endianess problems with old a.out tools. This makes building
some cross toolchains possible.

This also changes some utilities's behavior slightly:
- nm, strip, size now handle any a.out format they know about.
- ranlib complains if it detects mixed archives (several object
formats for different boxes).

In the presence of mixed objects, you still have file, ranlib or ld
to prevent you from getting too confused...


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 11-May-1998 niklas

Build nm ok for cross-envs


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.6 31-May-1997 deraadt

warn instead of warnx; kleink


Revision tags: OPENBSD_2_1_BASE
# 1.5 04-Apr-1997 deraadt

check MID field like strip(1) does; PR#149, mickey; fix by me


# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.3 26-Jun-1996 deraadt

rcsid


# 1.2 16-Jan-1996 deraadt

from netbsd; Use err() & warn()


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.55 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.54 03-Mar-2019 schwarze

on malloc(3) failure, gracefully abort processing of the current file
rather than crashing with a NULL pointer access;
patch from Benjamin Baier <programmer at netzbasis dot de>;
OK otto@ deraadt@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.53 27-Oct-2017 mpi

Use <elf.h> instead of <elf_abi.h>

ok jasper@, jca@, deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.52 12-Sep-2017 mpi

Include room for NUL-termination when calculating the length of archive
member name.

Fix an of by one found by sthen@ with MALLOC_OPTIONS=C.

From Matthew Martin, ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.51 09-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.50 13-Nov-2015 deraadt

ratchet pledge from the start; from Theo Buehler


# 1.49 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.48 05-Oct-2015 deraadt

tame "stdio rpath" works fine, as long as we sidestep the demangling
process which involves fork+execve....
ok doug


# 1.47 13-Aug-2015 miod

Grow -P (POSIX output) and -t (POSIX output radix) support. Several 3rd-party
software depend upon this.

Requested by feinerer@, ok millert@; manpage bits ok jmc@


Revision tags: OPENBSD_5_8_BASE
# 1.46 17-May-2015 guenther

Add 'D' to usage optstring. Prodded by jmc@


# 1.45 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.44 09-Apr-2015 guenther

ELF weak symbols are _not_ like a.out indirect symbols. Nothing in ELF is,
so remove N_INDR handling.

ok kettenis@


# 1.43 08-Apr-2015 guenther

Delete another piece of a.out detritus


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.41 28-Apr-2014 miod

Ignore IRIX6-compatible archive map on mips64 platform, since the mips64
toolchain creates them. This lets nm -w correctly return 0 for valid archives.

ok jasper@ deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.40 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.39 12-Nov-2013 deraadt

avoid math on void * pointers; delete an unused variable


# 1.38 12-Nov-2013 deraadt

remove more code accidentally left behind during the a.out purge


# 1.37 24-Oct-2013 miod

Redo 1.34+1.35, but ignore incorrect files in show_file() as done in 1.33.
Fixes nm output on archives on mips.


# 1.36 24-Oct-2013 deraadt

back out to 1.33, subtle bug being hunted...


# 1.35 21-Oct-2013 deraadt

remove a space that snuck into the output


# 1.34 19-Oct-2013 deraadt

Remove a.out/stab knowledge from nm.
(As a side effect of this repair, the -e option no longer reports that
all weak objects are functions)
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.33 06-Feb-2011 jasper

- nm -s omitted the symbol list for first object file in an archive. fix this
by forcing show_symtab() to restore its original file offset after processing.

fix from pr #6385.
ok miod@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.32 27-Oct-2009 deraadt

nm -V is silly, and prining the rcsid even more so


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.31 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.30 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.29 03-Jan-2005 espie

don't try to demangle C symbols if we're ELF.
looks okay mickey@


# 1.28 10-Oct-2004 mickey

now that no cpu assumptions are left in -- remove the cross-glue


# 1.27 09-Oct-2004 mickey

move out elf code into elf.c and generate 32 and 64 versions of it;
allow operation on size-mixed host-target as well as ensianess for
both a.out and elf (though a.out 64bit probably does not exist ;)
tested on hppa-sparc64-i386-vax intermixen


Revision tags: OPENBSD_3_6_BASE
# 1.26 11-Jul-2004 mickey

need to byteswap string table size before use for the alien endian a.out


# 1.25 04-May-2004 deraadt

spacing


# 1.24 29-Apr-2004 miod

Correctly report empty a.out objects as "no name list" instead of "bad format".

ok mickey@ millert@


Revision tags: OPENBSD_3_5_BASE
# 1.23 14-Jan-2004 millert

Fix the mmap case; inadequate testing on my part!


# 1.22 14-Jan-2004 millert

Fallback to malloc + pread if mmap fails; fixes "nm /dev/ksyms". OK mickey@


# 1.21 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.20 05-Jan-2004 mickey

nm digs elf and merges w/ size; millert@ ok


Revision tags: OPENBSD_3_4_BASE
# 1.19 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.18 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.17 05-Apr-2003 deraadt

snprintf; ok miod ho henning


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.14 17-Aug-2001 espie

Some missing protos. Use macros from <link.h> instead of rolling our own.


# 1.13 17-Aug-2001 espie

Show indirect symbols in -e mode.


# 1.12 16-Aug-2001 espie

-e switch, show extra symbol information such as weak symbol status.


# 1.11 31-May-2001 smart

- remove erealloc() wrapper function
- standard function prototypes
- remove extraneous exit(1) after an err(1,...)

Shrinks source by 11 lines and executable by 22 bytes on i386. deraadt@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.10 18-Feb-2001 espie

-C support.
Recognize -B, for better gnu-nm compatibility.


# 1.9 10-Nov-2000 provos

seperate -> separate, okay aaron@


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 10-May-1999 espie

Fixes endianess problems with old a.out tools. This makes building
some cross toolchains possible.

This also changes some utilities's behavior slightly:
- nm, strip, size now handle any a.out format they know about.
- ranlib complains if it detects mixed archives (several object
formats for different boxes).

In the presence of mixed objects, you still have file, ranlib or ld
to prevent you from getting too confused...


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 11-May-1998 niklas

Build nm ok for cross-envs


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.6 31-May-1997 deraadt

warn instead of warnx; kleink


Revision tags: OPENBSD_2_1_BASE
# 1.5 04-Apr-1997 deraadt

check MID field like strip(1) does; PR#149, mickey; fix by me


# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.3 26-Jun-1996 deraadt

rcsid


# 1.2 16-Jan-1996 deraadt

from netbsd; Use err() & warn()


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.54 03-Mar-2019 schwarze

on malloc(3) failure, gracefully abort processing of the current file
rather than crashing with a NULL pointer access;
patch from Benjamin Baier <programmer at netzbasis dot de>;
OK otto@ deraadt@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.53 27-Oct-2017 mpi

Use <elf.h> instead of <elf_abi.h>

ok jasper@, jca@, deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.52 12-Sep-2017 mpi

Include room for NUL-termination when calculating the length of archive
member name.

Fix an of by one found by sthen@ with MALLOC_OPTIONS=C.

From Matthew Martin, ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.51 09-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.50 13-Nov-2015 deraadt

ratchet pledge from the start; from Theo Buehler


# 1.49 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.48 05-Oct-2015 deraadt

tame "stdio rpath" works fine, as long as we sidestep the demangling
process which involves fork+execve....
ok doug


# 1.47 13-Aug-2015 miod

Grow -P (POSIX output) and -t (POSIX output radix) support. Several 3rd-party
software depend upon this.

Requested by feinerer@, ok millert@; manpage bits ok jmc@


Revision tags: OPENBSD_5_8_BASE
# 1.46 17-May-2015 guenther

Add 'D' to usage optstring. Prodded by jmc@


# 1.45 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.44 09-Apr-2015 guenther

ELF weak symbols are _not_ like a.out indirect symbols. Nothing in ELF is,
so remove N_INDR handling.

ok kettenis@


# 1.43 08-Apr-2015 guenther

Delete another piece of a.out detritus


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.41 28-Apr-2014 miod

Ignore IRIX6-compatible archive map on mips64 platform, since the mips64
toolchain creates them. This lets nm -w correctly return 0 for valid archives.

ok jasper@ deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.40 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.39 12-Nov-2013 deraadt

avoid math on void * pointers; delete an unused variable


# 1.38 12-Nov-2013 deraadt

remove more code accidentally left behind during the a.out purge


# 1.37 24-Oct-2013 miod

Redo 1.34+1.35, but ignore incorrect files in show_file() as done in 1.33.
Fixes nm output on archives on mips.


# 1.36 24-Oct-2013 deraadt

back out to 1.33, subtle bug being hunted...


# 1.35 21-Oct-2013 deraadt

remove a space that snuck into the output


# 1.34 19-Oct-2013 deraadt

Remove a.out/stab knowledge from nm.
(As a side effect of this repair, the -e option no longer reports that
all weak objects are functions)
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.33 06-Feb-2011 jasper

- nm -s omitted the symbol list for first object file in an archive. fix this
by forcing show_symtab() to restore its original file offset after processing.

fix from pr #6385.
ok miod@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.32 27-Oct-2009 deraadt

nm -V is silly, and prining the rcsid even more so


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.31 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.30 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.29 03-Jan-2005 espie

don't try to demangle C symbols if we're ELF.
looks okay mickey@


# 1.28 10-Oct-2004 mickey

now that no cpu assumptions are left in -- remove the cross-glue


# 1.27 09-Oct-2004 mickey

move out elf code into elf.c and generate 32 and 64 versions of it;
allow operation on size-mixed host-target as well as ensianess for
both a.out and elf (though a.out 64bit probably does not exist ;)
tested on hppa-sparc64-i386-vax intermixen


Revision tags: OPENBSD_3_6_BASE
# 1.26 11-Jul-2004 mickey

need to byteswap string table size before use for the alien endian a.out


# 1.25 04-May-2004 deraadt

spacing


# 1.24 29-Apr-2004 miod

Correctly report empty a.out objects as "no name list" instead of "bad format".

ok mickey@ millert@


Revision tags: OPENBSD_3_5_BASE
# 1.23 14-Jan-2004 millert

Fix the mmap case; inadequate testing on my part!


# 1.22 14-Jan-2004 millert

Fallback to malloc + pread if mmap fails; fixes "nm /dev/ksyms". OK mickey@


# 1.21 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.20 05-Jan-2004 mickey

nm digs elf and merges w/ size; millert@ ok


Revision tags: OPENBSD_3_4_BASE
# 1.19 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.18 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.17 05-Apr-2003 deraadt

snprintf; ok miod ho henning


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.14 17-Aug-2001 espie

Some missing protos. Use macros from <link.h> instead of rolling our own.


# 1.13 17-Aug-2001 espie

Show indirect symbols in -e mode.


# 1.12 16-Aug-2001 espie

-e switch, show extra symbol information such as weak symbol status.


# 1.11 31-May-2001 smart

- remove erealloc() wrapper function
- standard function prototypes
- remove extraneous exit(1) after an err(1,...)

Shrinks source by 11 lines and executable by 22 bytes on i386. deraadt@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.10 18-Feb-2001 espie

-C support.
Recognize -B, for better gnu-nm compatibility.


# 1.9 10-Nov-2000 provos

seperate -> separate, okay aaron@


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 10-May-1999 espie

Fixes endianess problems with old a.out tools. This makes building
some cross toolchains possible.

This also changes some utilities's behavior slightly:
- nm, strip, size now handle any a.out format they know about.
- ranlib complains if it detects mixed archives (several object
formats for different boxes).

In the presence of mixed objects, you still have file, ranlib or ld
to prevent you from getting too confused...


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 11-May-1998 niklas

Build nm ok for cross-envs


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.6 31-May-1997 deraadt

warn instead of warnx; kleink


Revision tags: OPENBSD_2_1_BASE
# 1.5 04-Apr-1997 deraadt

check MID field like strip(1) does; PR#149, mickey; fix by me


# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.3 26-Jun-1996 deraadt

rcsid


# 1.2 16-Jan-1996 deraadt

from netbsd; Use err() & warn()


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.53 27-Oct-2017 mpi

Use <elf.h> instead of <elf_abi.h>

ok jasper@, jca@, deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.52 12-Sep-2017 mpi

Include room for NUL-termination when calculating the length of archive
member name.

Fix an of by one found by sthen@ with MALLOC_OPTIONS=C.

From Matthew Martin, ok deraadt@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.51 09-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.50 13-Nov-2015 deraadt

ratchet pledge from the start; from Theo Buehler


# 1.49 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.48 05-Oct-2015 deraadt

tame "stdio rpath" works fine, as long as we sidestep the demangling
process which involves fork+execve....
ok doug


# 1.47 13-Aug-2015 miod

Grow -P (POSIX output) and -t (POSIX output radix) support. Several 3rd-party
software depend upon this.

Requested by feinerer@, ok millert@; manpage bits ok jmc@


Revision tags: OPENBSD_5_8_BASE
# 1.46 17-May-2015 guenther

Add 'D' to usage optstring. Prodded by jmc@


# 1.45 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.44 09-Apr-2015 guenther

ELF weak symbols are _not_ like a.out indirect symbols. Nothing in ELF is,
so remove N_INDR handling.

ok kettenis@


# 1.43 08-Apr-2015 guenther

Delete another piece of a.out detritus


Revision tags: OPENBSD_5_7_BASE
# 1.42 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_6_BASE
# 1.41 28-Apr-2014 miod

Ignore IRIX6-compatible archive map on mips64 platform, since the mips64
toolchain creates them. This lets nm -w correctly return 0 for valid archives.

ok jasper@ deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.40 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.39 12-Nov-2013 deraadt

avoid math on void * pointers; delete an unused variable


# 1.38 12-Nov-2013 deraadt

remove more code accidentally left behind during the a.out purge


# 1.37 24-Oct-2013 miod

Redo 1.34+1.35, but ignore incorrect files in show_file() as done in 1.33.
Fixes nm output on archives on mips.


# 1.36 24-Oct-2013 deraadt

back out to 1.33, subtle bug being hunted...


# 1.35 21-Oct-2013 deraadt

remove a space that snuck into the output


# 1.34 19-Oct-2013 deraadt

Remove a.out/stab knowledge from nm.
(As a side effect of this repair, the -e option no longer reports that
all weak objects are functions)
ok miod


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.33 06-Feb-2011 jasper

- nm -s omitted the symbol list for first object file in an archive. fix this
by forcing show_symtab() to restore its original file offset after processing.

fix from pr #6385.
ok miod@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.32 27-Oct-2009 deraadt

nm -V is silly, and prining the rcsid even more so


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.31 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.30 06-Aug-2007 sobrado

the ellipsis is not an optional argument; while here, sync the usage
and synopsis of commands

lots of good ideas by jmc@

ok jmc@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.29 03-Jan-2005 espie

don't try to demangle C symbols if we're ELF.
looks okay mickey@


# 1.28 10-Oct-2004 mickey

now that no cpu assumptions are left in -- remove the cross-glue


# 1.27 09-Oct-2004 mickey

move out elf code into elf.c and generate 32 and 64 versions of it;
allow operation on size-mixed host-target as well as ensianess for
both a.out and elf (though a.out 64bit probably does not exist ;)
tested on hppa-sparc64-i386-vax intermixen


Revision tags: OPENBSD_3_6_BASE
# 1.26 11-Jul-2004 mickey

need to byteswap string table size before use for the alien endian a.out


# 1.25 04-May-2004 deraadt

spacing


# 1.24 29-Apr-2004 miod

Correctly report empty a.out objects as "no name list" instead of "bad format".

ok mickey@ millert@


Revision tags: OPENBSD_3_5_BASE
# 1.23 14-Jan-2004 millert

Fix the mmap case; inadequate testing on my part!


# 1.22 14-Jan-2004 millert

Fallback to malloc + pread if mmap fails; fixes "nm /dev/ksyms". OK mickey@


# 1.21 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.20 05-Jan-2004 mickey

nm digs elf and merges w/ size; millert@ ok


Revision tags: OPENBSD_3_4_BASE
# 1.19 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.18 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.17 05-Apr-2003 deraadt

snprintf; ok miod ho henning


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.16 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.15 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_3_0_BASE
# 1.14 17-Aug-2001 espie

Some missing protos. Use macros from <link.h> instead of rolling our own.


# 1.13 17-Aug-2001 espie

Show indirect symbols in -e mode.


# 1.12 16-Aug-2001 espie

-e switch, show extra symbol information such as weak symbol status.


# 1.11 31-May-2001 smart

- remove erealloc() wrapper function
- standard function prototypes
- remove extraneous exit(1) after an err(1,...)

Shrinks source by 11 lines and executable by 22 bytes on i386. deraadt@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.10 18-Feb-2001 espie

-C support.
Recognize -B, for better gnu-nm compatibility.


# 1.9 10-Nov-2000 provos

seperate -> separate, okay aaron@


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.8 10-May-1999 espie

Fixes endianess problems with old a.out tools. This makes building
some cross toolchains possible.

This also changes some utilities's behavior slightly:
- nm, strip, size now handle any a.out format they know about.
- ranlib complains if it detects mixed archives (several object
formats for different boxes).

In the presence of mixed objects, you still have file, ranlib or ld
to prevent you from getting too confused...


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.7 11-May-1998 niklas

Build nm ok for cross-envs


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.6 31-May-1997 deraadt

warn instead of warnx; kleink


Revision tags: OPENBSD_2_1_BASE
# 1.5 04-Apr-1997 deraadt

check MID field like strip(1) does; PR#149, mickey; fix by me


# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


Revision tags: OPENBSD_2_0_BASE
# 1.3 26-Jun-1996 deraadt

rcsid


# 1.2 16-Jan-1996 deraadt

from netbsd; Use err() & warn()


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision