mirror of
https://github.com/openbsd/src.git
synced 2025-01-03 06:45:37 -08:00
Delete unused phdr functions; move declarations for functions internal to
elf.c to that file ok mpi@
This commit is contained in:
parent
6dd6a70c1e
commit
7feae41f19
@ -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)
|
||||
{
|
||||
@ -236,29 +215,6 @@ elf_fix_shdrs(Elf_Ehdr *eh, Elf_Shdr *shdr)
|
||||
return (1);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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 *);
|
||||
|
Loading…
Reference in New Issue
Block a user