History log of /openbsd-current/usr.bin/nm/elf.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.39 07-Nov-2021 semarie

nm: add some .text.* support for symbols

.text.* are generated when using -ffunction-sections.

makes nm(1) to correctly identify the function symbols as N_TEXT.

found while debugging librsvg build error, where some symbols where not found by libtool(1) (which is using nm(1)).

ok gkoehler@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.38 22-Nov-2020 jsg

fix typo; from Kris Katterjohn


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.37 14-Dec-2018 guenther

Delete unused phdr functions; move declarations for functions internal to
elf.c to that file

ok mpi@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Dec-2017 deraadt

recognize .openbsd.randomdata section and indicate it roughly, so
that objects within it are identified as being in read-only space.
ok guenther


# 1.35 27-Oct-2017 mpi

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

ok jasper@, jca@, deraadt@


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

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


# 1.33 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.32 23-Jun-2015 semarie

This patch ensure that when an error is detected, the freed variables in
elf_symloadx() are reinitialised.

Else show_file() in nm.c will used these variables, even if they has
just been freed. (nm.c +689).

Problem found by afl.

ok miod@


# 1.31 23-Jun-2015 semarie

This patch ensure that e_shentsize (sections header's size in bytes) is
big enough to fill at least one Elf_Shdr.

While here, inverts calloc() arguments to be calloc(nmemb, size),
according to fread() call after.

This problem was found with afl, with e_shentsize=1.

ok miod@


# 1.30 23-Jun-2015 semarie

corrects a read after bound that occurs in strcmp (line just
after the added bound check).

Found with afl.

ok miod@


# 1.29 23-Jun-2015 semarie

add some check before accessing data:
- if section header table is be present
- consistency of section header table size

ok miod@


# 1.28 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.27 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@


Revision tags: OPENBSD_5_7_BASE
# 1.26 06-Feb-2015 millert

SIZE_MAX is standard, we should be using it in preference to the
obsolete SIZE_T_MAX. OK miod@ beck@


# 1.25 19-Jan-2015 miod

Missing initialization; tjenahej@speedmail.se


# 1.24 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_5_BASE OPENBSD_5_6_BASE
# 1.23 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.22 13-Nov-2013 deraadt

proto and such cleanup
ok guenther


Revision tags: OPENBSD_5_4_BASE
# 1.21 30-Mar-2013 miod

Correctly report `weak' status of non-function symbols. Makes nm agree with
objdump -t on, say, _DYNAMIC in libpthread.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.20 28-Sep-2011 uwe

Support symbols in .tbss and .tdata ELF sections

With this change nm(1) prints the expected symbol type ('B' or 'D')
for variables in the .tbss and .tdata sections respectively, instead
of '?'. This would be what binutils do for non-automatic variables
that are marked as thread-local with the __thread attribute in GCC.

help and ok miod@, guenther@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


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

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


Revision tags: OPENBSD_4_2_BASE
# 1.17 18-Apr-2007 miod

Fix a NULL dereference if the symbol table size is zero; ok millert@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.16 08-Feb-2007 ray

Do all allocation and deallocation of shstr in elf_symload() to
prevent double-freeing shstr.

Also don't free known NULL values (*pnames and *psnames).

Initially inspired by Charles Longeau's first diff to tech@; he
later sent a second diff to tech@ nearly identical to this commit.
Freaky.

OK mickey@.


# 1.15 07-Feb-2007 mickey

check st_name validity also check for overflow and not only for zero; found by Charles Longeau <chl@tuxfamily.org>


# 1.14 30-Sep-2006 kettenis

Some fixes for running nm on ELF binaries.
- Fix printing the symbol type of undefined symbols.
- Fall back onto the dynamic symbol table if the normal symbol table is not
available (i.e. if the binary has been stripped).

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.13 19-Jan-2005 grange

Add elf{32,64}_load_phdrs() for loading program headers.

ok mickey@


# 1.12 11-Oct-2004 mickey

add rcisd[]


# 1.11 10-Oct-2004 mickey

parse the cpu-specific ids based on the e_machine


# 1.10 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


# 1.9 09-Oct-2004 mickey

factor out code for mapping section index into nlist type


Revision tags: OPENBSD_3_6_BASE
# 1.8 20-Aug-2004 mickey

grok STT_SECTION and beautify STT_OBJECT


# 1.7 19-Aug-2004 mickey

STT_FUNC can be an absolute too


# 1.6 04-May-2004 mickey

dig .plt*, .got*, .init, .fini sections


# 1.5 30-Mar-2004 mickey

no need to force N_EXT as deducted later from type


# 1.4 30-Mar-2004 mickey

there is more than one way to define symbol type in elf...; kill a debugging printf too


# 1.3 30-Mar-2004 mickey

translate names in .sbss section as static N_BSS; found by drahn@


Revision tags: OPENBSD_3_5_BASE
# 1.2 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.1 05-Jan-2004 mickey

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


# 1.38 22-Nov-2020 jsg

fix typo; from Kris Katterjohn


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.37 14-Dec-2018 guenther

Delete unused phdr functions; move declarations for functions internal to
elf.c to that file

ok mpi@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Dec-2017 deraadt

recognize .openbsd.randomdata section and indicate it roughly, so
that objects within it are identified as being in read-only space.
ok guenther


# 1.35 27-Oct-2017 mpi

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

ok jasper@, jca@, deraadt@


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

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


# 1.33 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.32 23-Jun-2015 semarie

This patch ensure that when an error is detected, the freed variables in
elf_symloadx() are reinitialised.

Else show_file() in nm.c will used these variables, even if they has
just been freed. (nm.c +689).

Problem found by afl.

ok miod@


# 1.31 23-Jun-2015 semarie

This patch ensure that e_shentsize (sections header's size in bytes) is
big enough to fill at least one Elf_Shdr.

While here, inverts calloc() arguments to be calloc(nmemb, size),
according to fread() call after.

This problem was found with afl, with e_shentsize=1.

ok miod@


# 1.30 23-Jun-2015 semarie

corrects a read after bound that occurs in strcmp (line just
after the added bound check).

Found with afl.

ok miod@


# 1.29 23-Jun-2015 semarie

add some check before accessing data:
- if section header table is be present
- consistency of section header table size

ok miod@


# 1.28 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.27 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@


Revision tags: OPENBSD_5_7_BASE
# 1.26 06-Feb-2015 millert

SIZE_MAX is standard, we should be using it in preference to the
obsolete SIZE_T_MAX. OK miod@ beck@


# 1.25 19-Jan-2015 miod

Missing initialization; tjenahej@speedmail.se


# 1.24 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_5_BASE OPENBSD_5_6_BASE
# 1.23 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.22 13-Nov-2013 deraadt

proto and such cleanup
ok guenther


Revision tags: OPENBSD_5_4_BASE
# 1.21 30-Mar-2013 miod

Correctly report `weak' status of non-function symbols. Makes nm agree with
objdump -t on, say, _DYNAMIC in libpthread.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.20 28-Sep-2011 uwe

Support symbols in .tbss and .tdata ELF sections

With this change nm(1) prints the expected symbol type ('B' or 'D')
for variables in the .tbss and .tdata sections respectively, instead
of '?'. This would be what binutils do for non-automatic variables
that are marked as thread-local with the __thread attribute in GCC.

help and ok miod@, guenther@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


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

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


Revision tags: OPENBSD_4_2_BASE
# 1.17 18-Apr-2007 miod

Fix a NULL dereference if the symbol table size is zero; ok millert@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.16 08-Feb-2007 ray

Do all allocation and deallocation of shstr in elf_symload() to
prevent double-freeing shstr.

Also don't free known NULL values (*pnames and *psnames).

Initially inspired by Charles Longeau's first diff to tech@; he
later sent a second diff to tech@ nearly identical to this commit.
Freaky.

OK mickey@.


# 1.15 07-Feb-2007 mickey

check st_name validity also check for overflow and not only for zero; found by Charles Longeau <chl@tuxfamily.org>


# 1.14 30-Sep-2006 kettenis

Some fixes for running nm on ELF binaries.
- Fix printing the symbol type of undefined symbols.
- Fall back onto the dynamic symbol table if the normal symbol table is not
available (i.e. if the binary has been stripped).

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.13 19-Jan-2005 grange

Add elf{32,64}_load_phdrs() for loading program headers.

ok mickey@


# 1.12 11-Oct-2004 mickey

add rcisd[]


# 1.11 10-Oct-2004 mickey

parse the cpu-specific ids based on the e_machine


# 1.10 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


# 1.9 09-Oct-2004 mickey

factor out code for mapping section index into nlist type


Revision tags: OPENBSD_3_6_BASE
# 1.8 20-Aug-2004 mickey

grok STT_SECTION and beautify STT_OBJECT


# 1.7 19-Aug-2004 mickey

STT_FUNC can be an absolute too


# 1.6 04-May-2004 mickey

dig .plt*, .got*, .init, .fini sections


# 1.5 30-Mar-2004 mickey

no need to force N_EXT as deducted later from type


# 1.4 30-Mar-2004 mickey

there is more than one way to define symbol type in elf...; kill a debugging printf too


# 1.3 30-Mar-2004 mickey

translate names in .sbss section as static N_BSS; found by drahn@


Revision tags: OPENBSD_3_5_BASE
# 1.2 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.1 05-Jan-2004 mickey

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


# 1.37 14-Dec-2018 guenther

Delete unused phdr functions; move declarations for functions internal to
elf.c to that file

ok mpi@


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.36 09-Dec-2017 deraadt

recognize .openbsd.randomdata section and indicate it roughly, so
that objects within it are identified as being in read-only space.
ok guenther


# 1.35 27-Oct-2017 mpi

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

ok jasper@, jca@, deraadt@


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

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


# 1.33 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.32 23-Jun-2015 semarie

This patch ensure that when an error is detected, the freed variables in
elf_symloadx() are reinitialised.

Else show_file() in nm.c will used these variables, even if they has
just been freed. (nm.c +689).

Problem found by afl.

ok miod@


# 1.31 23-Jun-2015 semarie

This patch ensure that e_shentsize (sections header's size in bytes) is
big enough to fill at least one Elf_Shdr.

While here, inverts calloc() arguments to be calloc(nmemb, size),
according to fread() call after.

This problem was found with afl, with e_shentsize=1.

ok miod@


# 1.30 23-Jun-2015 semarie

corrects a read after bound that occurs in strcmp (line just
after the added bound check).

Found with afl.

ok miod@


# 1.29 23-Jun-2015 semarie

add some check before accessing data:
- if section header table is be present
- consistency of section header table size

ok miod@


# 1.28 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.27 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@


Revision tags: OPENBSD_5_7_BASE
# 1.26 06-Feb-2015 millert

SIZE_MAX is standard, we should be using it in preference to the
obsolete SIZE_T_MAX. OK miod@ beck@


# 1.25 19-Jan-2015 miod

Missing initialization; tjenahej@speedmail.se


# 1.24 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_5_BASE OPENBSD_5_6_BASE
# 1.23 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.22 13-Nov-2013 deraadt

proto and such cleanup
ok guenther


Revision tags: OPENBSD_5_4_BASE
# 1.21 30-Mar-2013 miod

Correctly report `weak' status of non-function symbols. Makes nm agree with
objdump -t on, say, _DYNAMIC in libpthread.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.20 28-Sep-2011 uwe

Support symbols in .tbss and .tdata ELF sections

With this change nm(1) prints the expected symbol type ('B' or 'D')
for variables in the .tbss and .tdata sections respectively, instead
of '?'. This would be what binutils do for non-automatic variables
that are marked as thread-local with the __thread attribute in GCC.

help and ok miod@, guenther@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


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

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


Revision tags: OPENBSD_4_2_BASE
# 1.17 18-Apr-2007 miod

Fix a NULL dereference if the symbol table size is zero; ok millert@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.16 08-Feb-2007 ray

Do all allocation and deallocation of shstr in elf_symload() to
prevent double-freeing shstr.

Also don't free known NULL values (*pnames and *psnames).

Initially inspired by Charles Longeau's first diff to tech@; he
later sent a second diff to tech@ nearly identical to this commit.
Freaky.

OK mickey@.


# 1.15 07-Feb-2007 mickey

check st_name validity also check for overflow and not only for zero; found by Charles Longeau <chl@tuxfamily.org>


# 1.14 30-Sep-2006 kettenis

Some fixes for running nm on ELF binaries.
- Fix printing the symbol type of undefined symbols.
- Fall back onto the dynamic symbol table if the normal symbol table is not
available (i.e. if the binary has been stripped).

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.13 19-Jan-2005 grange

Add elf{32,64}_load_phdrs() for loading program headers.

ok mickey@


# 1.12 11-Oct-2004 mickey

add rcisd[]


# 1.11 10-Oct-2004 mickey

parse the cpu-specific ids based on the e_machine


# 1.10 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


# 1.9 09-Oct-2004 mickey

factor out code for mapping section index into nlist type


Revision tags: OPENBSD_3_6_BASE
# 1.8 20-Aug-2004 mickey

grok STT_SECTION and beautify STT_OBJECT


# 1.7 19-Aug-2004 mickey

STT_FUNC can be an absolute too


# 1.6 04-May-2004 mickey

dig .plt*, .got*, .init, .fini sections


# 1.5 30-Mar-2004 mickey

no need to force N_EXT as deducted later from type


# 1.4 30-Mar-2004 mickey

there is more than one way to define symbol type in elf...; kill a debugging printf too


# 1.3 30-Mar-2004 mickey

translate names in .sbss section as static N_BSS; found by drahn@


Revision tags: OPENBSD_3_5_BASE
# 1.2 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.1 05-Jan-2004 mickey

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


# 1.36 09-Dec-2017 deraadt

recognize .openbsd.randomdata section and indicate it roughly, so
that objects within it are identified as being in read-only space.
ok guenther


# 1.35 27-Oct-2017 mpi

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

ok jasper@, jca@, deraadt@


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

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


# 1.33 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.32 23-Jun-2015 semarie

This patch ensure that when an error is detected, the freed variables in
elf_symloadx() are reinitialised.

Else show_file() in nm.c will used these variables, even if they has
just been freed. (nm.c +689).

Problem found by afl.

ok miod@


# 1.31 23-Jun-2015 semarie

This patch ensure that e_shentsize (sections header's size in bytes) is
big enough to fill at least one Elf_Shdr.

While here, inverts calloc() arguments to be calloc(nmemb, size),
according to fread() call after.

This problem was found with afl, with e_shentsize=1.

ok miod@


# 1.30 23-Jun-2015 semarie

corrects a read after bound that occurs in strcmp (line just
after the added bound check).

Found with afl.

ok miod@


# 1.29 23-Jun-2015 semarie

add some check before accessing data:
- if section header table is be present
- consistency of section header table size

ok miod@


# 1.28 17-May-2015 guenther

Add -D option for displaying the dynamic symbol table

ok miod@


# 1.27 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@


Revision tags: OPENBSD_5_7_BASE
# 1.26 06-Feb-2015 millert

SIZE_MAX is standard, we should be using it in preference to the
obsolete SIZE_T_MAX. OK miod@ beck@


# 1.25 19-Jan-2015 miod

Missing initialization; tjenahej@speedmail.se


# 1.24 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_5_BASE OPENBSD_5_6_BASE
# 1.23 26-Nov-2013 deraadt

unsigned char casts for ctype
ok krw


# 1.22 13-Nov-2013 deraadt

proto and such cleanup
ok guenther


Revision tags: OPENBSD_5_4_BASE
# 1.21 30-Mar-2013 miod

Correctly report `weak' status of non-function symbols. Makes nm agree with
objdump -t on, say, _DYNAMIC in libpthread.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.20 28-Sep-2011 uwe

Support symbols in .tbss and .tdata ELF sections

With this change nm(1) prints the expected symbol type ('B' or 'D')
for variables in the .tbss and .tdata sections respectively, instead
of '?'. This would be what binutils do for non-automatic variables
that are marked as thread-local with the __thread attribute in GCC.

help and ok miod@, guenther@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


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

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


Revision tags: OPENBSD_4_2_BASE
# 1.17 18-Apr-2007 miod

Fix a NULL dereference if the symbol table size is zero; ok millert@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.16 08-Feb-2007 ray

Do all allocation and deallocation of shstr in elf_symload() to
prevent double-freeing shstr.

Also don't free known NULL values (*pnames and *psnames).

Initially inspired by Charles Longeau's first diff to tech@; he
later sent a second diff to tech@ nearly identical to this commit.
Freaky.

OK mickey@.


# 1.15 07-Feb-2007 mickey

check st_name validity also check for overflow and not only for zero; found by Charles Longeau <chl@tuxfamily.org>


# 1.14 30-Sep-2006 kettenis

Some fixes for running nm on ELF binaries.
- Fix printing the symbol type of undefined symbols.
- Fall back onto the dynamic symbol table if the normal symbol table is not
available (i.e. if the binary has been stripped).

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.13 19-Jan-2005 grange

Add elf{32,64}_load_phdrs() for loading program headers.

ok mickey@


# 1.12 11-Oct-2004 mickey

add rcisd[]


# 1.11 10-Oct-2004 mickey

parse the cpu-specific ids based on the e_machine


# 1.10 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


# 1.9 09-Oct-2004 mickey

factor out code for mapping section index into nlist type


Revision tags: OPENBSD_3_6_BASE
# 1.8 20-Aug-2004 mickey

grok STT_SECTION and beautify STT_OBJECT


# 1.7 19-Aug-2004 mickey

STT_FUNC can be an absolute too


# 1.6 04-May-2004 mickey

dig .plt*, .got*, .init, .fini sections


# 1.5 30-Mar-2004 mickey

no need to force N_EXT as deducted later from type


# 1.4 30-Mar-2004 mickey

there is more than one way to define symbol type in elf...; kill a debugging printf too


# 1.3 30-Mar-2004 mickey

translate names in .sbss section as static N_BSS; found by drahn@


Revision tags: OPENBSD_3_5_BASE
# 1.2 13-Jan-2004 mickey

kill unused local vars; from deraadt@


# 1.1 05-Jan-2004 mickey

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