summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2011-09-28 19:58:15 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2011-09-28 19:58:15 +0000
commit7bc5d2b90ac66b2b2d24ee69fa7ec4e21788ce37 (patch)
tree45b29cbed222b3da60ae758243e29fee701dfb63
parent5a584962ab8cee0b65e69bcd3da8ce591fb3ef5e (diff)
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@
-rw-r--r--usr.bin/nm/elf.c11
-rw-r--r--usr.bin/nm/nm.18
2 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c
index ebe939247e8..e81a421f539 100644
--- a/usr.bin/nm/elf.c
+++ b/usr.bin/nm/elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elf.c,v 1.19 2009/10/27 23:59:41 deraadt Exp $ */
+/* $OpenBSD: elf.c,v 1.20 2011/09/28 19:58:14 uwe Exp $ */
/*
* Copyright (c) 2003 Michael Shalayeff
@@ -90,7 +90,9 @@
#endif
#define ELF_SDATA ".sdata"
+#define ELF_TDATA ".tdata"
#define ELF_SBSS ".sbss"
+#define ELF_TBSS ".tbss"
#define ELF_PLT ".plt"
#ifndef SHN_MIPS_ACOMMON
@@ -293,7 +295,7 @@ elf_shn2type(Elf_Ehdr *eh, u_int shn, const char *sn)
break;
default:
- /* beyond 8 a table-driven binsearch shall be used */
+ /* TODO: beyond 8 a table-driven binsearch should be used */
if (sn == NULL)
return (-1);
else if (!strcmp(sn, ELF_TEXT))
@@ -304,10 +306,14 @@ elf_shn2type(Elf_Ehdr *eh, u_int shn, const char *sn)
return (N_DATA);
else if (!strcmp(sn, ELF_SDATA))
return (N_DATA);
+ else if (!strcmp(sn, ELF_TDATA))
+ return (N_DATA);
else if (!strcmp(sn, ELF_BSS))
return (N_BSS);
else if (!strcmp(sn, ELF_SBSS))
return (N_BSS);
+ else if (!strcmp(sn, ELF_TBSS))
+ return (N_BSS);
else if (!strncmp(sn, ELF_GOT, sizeof(ELF_GOT) - 1))
return (N_DATA);
else if (!strncmp(sn, ELF_PLT, sizeof(ELF_PLT) - 1))
@@ -343,6 +349,7 @@ elf2nlist(Elf_Sym *sym, Elf_Ehdr *eh, Elf_Shdr *shdr, char *shstr, struct nlist
switch (stt = ELF_ST_TYPE(sym->st_info)) {
case STT_NOTYPE:
case STT_OBJECT:
+ case STT_TLS:
type = elf_shn2type(eh, sym->st_shndx, sn);
if (type < 0) {
if (sn == NULL)
diff --git a/usr.bin/nm/nm.1 b/usr.bin/nm/nm.1
index c1eccff39bd..faf3821992b 100644
--- a/usr.bin/nm/nm.1
+++ b/usr.bin/nm/nm.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: nm.1,v 1.22 2009/10/27 23:51:21 deraadt Exp $
+.\" $OpenBSD: nm.1,v 1.23 2011/09/28 19:58:14 uwe Exp $
.\" $NetBSD: nm.1,v 1.3 1995/08/31 23:41:58 jtc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@@ -30,7 +30,7 @@
.\"
.\" @(#)nm.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: October 27 2009 $
+.Dd $Mdocdate: September 28 2011 $
.Dt NM 1
.Os
.Sh NAME
@@ -99,11 +99,11 @@ option)
.It Li A
absolute
.It Li B
-bss segment symbol
+bss or tbss segment symbol
.It Li C
common symbol
.It Li D
-data segment symbol
+data or tdata segment symbol
.It Li I
indirect reference (alias to other symbol)
.It Li F