aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-02-25 01:15:21 +0000
committerMark Johnston <markj@FreeBSD.org>2023-02-25 01:16:51 +0000
commit49e3972afc1112f95863a04cea7a4401b78dfd1f (patch)
tree6244c8be8baec55f4d4713f176557d1e01168e81
parentf4f5e69c84df74e8834aed173af1127b1ff50970 (diff)
downloadsrc-49e3972afc1112f95863a04cea7a4401b78dfd1f.tar.gz
src-49e3972afc1112f95863a04cea7a4401b78dfd1f.zip
lockstat: Use gelf.h instead of playing games with the preprocessor
This reverts a portion of 1477dd823ee ("Merge OpenZFS support in to HEAD."). No functional change intended. MFC after: 1 week
-rw-r--r--cddl/contrib/opensolaris/cmd/lockstat/sym.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/cddl/contrib/opensolaris/cmd/lockstat/sym.c b/cddl/contrib/opensolaris/cmd/lockstat/sym.c
index b5366c566857..7516e7d435f4 100644
--- a/cddl/contrib/opensolaris/cmd/lockstat/sym.c
+++ b/cddl/contrib/opensolaris/cmd/lockstat/sym.c
@@ -42,6 +42,7 @@
#include <libelf.h>
#include <link.h>
#include <elf.h>
+#include <gelf.h>
#ifdef illumos
#include <sys/machelf.h>
@@ -54,7 +55,6 @@
#endif
#include <sys/cpuvar.h>
-
typedef struct syment {
uintptr_t addr;
char *name;
@@ -73,11 +73,6 @@ static char maxsymname[64];
#endif
#endif
-#define __sElfN(x) typedef __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) x
-__sElfN(Sym);
-__sElfN(Shdr);
-#define elf_getshdr __elfN(getshdr)
-
static void
add_symbol(char *name, uintptr_t addr, size_t size)
{
@@ -174,7 +169,7 @@ symtab_init(void)
{
Elf *elf;
Elf_Scn *scn = NULL;
- Sym *symtab, *symp, *lastsym;
+ GElf_Sym *symtab, *symp, *lastsym;
char *strtab;
uint_t cnt;
int fd;
@@ -198,13 +193,13 @@ symtab_init(void)
(void) elf_version(EV_CURRENT);
elf = elf_begin(fd, ELF_C_READ, NULL);
-
for (cnt = 1; (scn = elf_nextscn(elf, scn)) != NULL; cnt++) {
- Shdr *shdr = elf_getshdr(scn);
- if (shdr->sh_type == SHT_SYMTAB) {
- symtab = (Sym *)elf_getdata(scn, NULL)->d_buf;
- nsyms = shdr->sh_size / shdr->sh_entsize;
- strindex = shdr->sh_link;
+ GElf_Shdr shdr;
+ (void) gelf_getshdr(scn, &shdr);
+ if (shdr.sh_type == SHT_SYMTAB) {
+ symtab = (GElf_Sym *)elf_getdata(scn, NULL)->d_buf;
+ nsyms = shdr.sh_size / shdr.sh_entsize;
+ strindex = shdr.sh_link;
}
}