diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2018-12-14 19:56:03 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2018-12-14 19:56:03 +0000 |
commit | 14a516f60710e424fc8584cd5bc95767d958c1c1 (patch) | |
tree | 3d36ed4468f5d26c471dd13a721ff65dc82721fe /usr.bin/nm | |
parent | 44215840b33cabcc87d121720457f201203d0406 (diff) |
Delete unused phdr functions; move declarations for functions internal to
elf.c to that file
ok mpi@
Diffstat (limited to 'usr.bin/nm')
-rw-r--r-- | usr.bin/nm/elf.c | 68 | ||||
-rw-r--r-- | usr.bin/nm/elfuncs.h | 18 |
2 files changed, 13 insertions, 73 deletions
diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c index 955c07eceba..4d386011898 100644 --- a/usr.bin/nm/elf.c +++ b/usr.bin/nm/elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf.c,v 1.36 2017/12/09 06:39:04 deraadt Exp $ */ +/* $OpenBSD: elf.c,v 1.37 2018/12/14 19:56:02 guenther Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -51,9 +51,7 @@ #define swap_quarter swap16 #define elf_fix_header elf32_fix_header #define elf_load_shdrs elf32_load_shdrs -#define elf_load_phdrs elf32_load_phdrs #define elf_fix_shdrs elf32_fix_shdrs -#define elf_fix_phdrs elf32_fix_phdrs #define elf_fix_sym elf32_fix_sym #define elf_size elf32_size #define elf_symloadx elf32_symloadx @@ -76,9 +74,7 @@ #define swap_quarter swap16 #define elf_fix_header elf64_fix_header #define elf_load_shdrs elf64_load_shdrs -#define elf_load_phdrs elf64_load_phdrs #define elf_fix_shdrs elf64_fix_shdrs -#define elf_fix_phdrs elf64_fix_phdrs #define elf_fix_sym elf64_fix_sym #define elf_size elf64_size #define elf_symloadx elf64_symloadx @@ -115,8 +111,17 @@ #define STT_PARISC_MILLI STT_LOPROC + 0 #endif -int elf_shn2type(Elf_Ehdr *, u_int, const char *); -int elf2nlist(Elf_Sym *, Elf_Ehdr *, Elf_Shdr *, char *, struct xnlist *); + +static int elf_fix_header(Elf_Ehdr *); +static int elf_fix_shdrs(Elf_Ehdr *, Elf_Shdr *); +static int elf_fix_sym(Elf_Ehdr *, Elf_Sym *); +static int elf_shn2type(Elf_Ehdr *, u_int _shn, const char *_sn); +static int elf2nlist(Elf_Sym *, Elf_Ehdr *, Elf_Shdr *, char *_shstr, + struct xnlist *_np); +static int elf_symloadx(const char *_name, FILE *, off_t, Elf_Ehdr *, + Elf_Shdr *, char *_shstr, long _shstrsize, struct xnlist **_pnames, + struct xnlist ***_psnames, size_t *_pstabsize, int *_pnrawnames, + const char *_strtab, const char *_symtab); int elf_fix_header(Elf_Ehdr *eh) @@ -185,32 +190,6 @@ elf_load_shdrs(const char *name, FILE *fp, off_t foff, Elf_Ehdr *head) return (shdr); } -Elf_Phdr * -elf_load_phdrs(const char *name, FILE *fp, off_t foff, Elf_Ehdr *head) -{ - Elf_Phdr *phdr; - - if ((phdr = calloc(head->e_phentsize, head->e_phnum)) == NULL) { - warn("%s: malloc phdr", name); - return (NULL); - } - - if (fseeko(fp, foff + head->e_phoff, SEEK_SET)) { - warn("%s: fseeko", name); - free(phdr); - return (NULL); - } - - if (fread(phdr, head->e_phentsize, head->e_phnum, fp) != head->e_phnum) { - warnx("%s: premature EOF", name); - free(phdr); - return (NULL); - } - - elf_fix_phdrs(head, phdr); - return (phdr); -} - int elf_fix_shdrs(Elf_Ehdr *eh, Elf_Shdr *shdr) { @@ -237,29 +216,6 @@ elf_fix_shdrs(Elf_Ehdr *eh, Elf_Shdr *shdr) } int -elf_fix_phdrs(Elf_Ehdr *eh, Elf_Phdr *phdr) -{ - int i; - - /* nothing to do */ - if (eh->e_ident[EI_DATA] == ELF_TARG_DATA) - return (0); - - for (i = eh->e_phnum; i--; phdr++) { - phdr->p_type = swap32(phdr->p_type); - phdr->p_flags = swap32(phdr->p_flags); - phdr->p_offset = swap_off(phdr->p_offset); - phdr->p_vaddr = swap_addr(phdr->p_vaddr); - phdr->p_paddr = swap_addr(phdr->p_paddr); - phdr->p_filesz = swap_xword(phdr->p_filesz); - phdr->p_memsz = swap_xword(phdr->p_memsz); - phdr->p_align = swap_xword(phdr->p_align); - } - - return (1); -} - -int elf_fix_sym(Elf_Ehdr *eh, Elf_Sym *sym) { /* nothing to do */ diff --git a/usr.bin/nm/elfuncs.h b/usr.bin/nm/elfuncs.h index e1f1977c2f2..6b10bbbfdf2 100644 --- a/usr.bin/nm/elfuncs.h +++ b/usr.bin/nm/elfuncs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: elfuncs.h,v 1.5 2015/08/13 19:13:28 miod Exp $ */ +/* $OpenBSD: elfuncs.h,v 1.6 2018/12/14 19:56:02 guenther Exp $ */ /* * Copyright (c) 2004 Michael Shalayeff @@ -28,28 +28,12 @@ extern char *stab; -int elf32_fix_header(Elf32_Ehdr *eh); Elf32_Shdr*elf32_load_shdrs(const char *, FILE *, off_t, Elf32_Ehdr *); -Elf32_Phdr*elf32_load_phdrs(const char *, FILE *, off_t, Elf32_Ehdr *); -int elf32_fix_shdrs(Elf32_Ehdr *eh, Elf32_Shdr *shdr); -int elf32_fix_phdrs(Elf32_Ehdr *eh, Elf32_Phdr *phdr); -int elf32_fix_sym(Elf32_Ehdr *eh, Elf32_Sym *sym); int elf32_size(Elf32_Ehdr *, Elf32_Shdr *, u_long *, u_long *, u_long *); -int elf32_symloadx(const char *, FILE *, off_t, Elf32_Ehdr *, Elf32_Shdr *, - char *, long, struct xnlist **, struct xnlist ***, size_t *, int *, - const char *, const char *); int elf32_symload(const char *, FILE *, off_t, Elf32_Ehdr *, Elf32_Shdr *, struct xnlist **, struct xnlist ***, size_t *, int *); -int elf64_fix_header(Elf64_Ehdr *eh); Elf64_Shdr*elf64_load_shdrs(const char *, FILE *, off_t, Elf64_Ehdr *); -Elf64_Phdr*elf64_load_phdrs(const char *, FILE *, off_t, Elf64_Ehdr *); -int elf64_fix_shdrs(Elf64_Ehdr *eh, Elf64_Shdr *shdr); -int elf64_fix_phdrs(Elf64_Ehdr *eh, Elf64_Phdr *phdr); -int elf64_fix_sym(Elf64_Ehdr *eh, Elf64_Sym *sym); int elf64_size(Elf64_Ehdr *, Elf64_Shdr *, u_long *, u_long *, u_long *); -int elf64_symloadx(const char *, FILE *, off_t, Elf64_Ehdr *, Elf64_Shdr *, - char *, long, struct xnlist **, struct xnlist ***, size_t *, int *, - const char *, const char *); int elf64_symload(const char *, FILE *, off_t, Elf64_Ehdr *, Elf64_Shdr *, struct xnlist **, struct xnlist ***, size_t *, int *); |