Skip to content

Commit

Permalink
lockstat: Use gelf.h instead of playing games with the preprocessor
Browse files Browse the repository at this point in the history
This reverts a portion of 1477dd8 ("Merge OpenZFS support in to
HEAD.").  No functional change intended.

MFC after:	1 week
  • Loading branch information
markjdb committed Feb 25, 2023
1 parent f4f5e69 commit 49e3972
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions cddl/contrib/opensolaris/cmd/lockstat/sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <libelf.h>
#include <link.h>
#include <elf.h>
#include <gelf.h>
#ifdef illumos
#include <sys/machelf.h>

Expand All @@ -54,7 +55,6 @@
#endif
#include <sys/cpuvar.h>


typedef struct syment {
uintptr_t addr;
char *name;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 49e3972

Please sign in to comment.