mirror of
https://github.com/openbsd/src.git
synced 2025-01-03 06:45:37 -08:00
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@
This commit is contained in:
parent
000399a40c
commit
1f6470382c
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user