* elfcode.h: Convert to C90, remove unneeded casts and prototypes.

* elfcore.h: Likewise.
	* elflink.c: Likewise.
	* elflink.h: Likewise.
	* elf.c (sym_is_global): Remove INLINE.
	(align_file_position): Replace INLINE with inline.
	* elfcode.h (elf_swap_dyn_in, elf_swap_dyn_out): Remove INLINE.
	(elf_file_p): Replace INLINE with inline.
This commit is contained in:
Alan Modra 2003-08-04 09:39:46 +00:00
parent 2a36a1175e
commit 268b6b3931
6 changed files with 474 additions and 719 deletions

View file

@ -1,3 +1,14 @@
2003-08-04 Alan Modra <amodra@bigpond.net.au>
* elfcode.h: Convert to C90, remove unneeded casts and prototypes.
* elfcore.h: Likewise.
* elflink.c: Likewise.
* elflink.h: Likewise.
* elf.c (sym_is_global): Remove INLINE.
(align_file_position): Replace INLINE with inline.
* elfcode.h (elf_swap_dyn_in, elf_swap_dyn_out): Remove INLINE.
(elf_file_p): Replace INLINE with inline.
2003-08-02 Kaz Kojima <kkojima@rr.iij4u.or.jp> 2003-08-02 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* elf32-sh.c (sh_elf_check_relocs): Don't set DF_TEXTREL here. * elf32-sh.c (sh_elf_check_relocs): Don't set DF_TEXTREL here.

View file

@ -2868,7 +2868,7 @@ assign_section_numbers (bfd *abfd)
/* Map symbol from it's internal number to the external number, moving /* Map symbol from it's internal number to the external number, moving
all local symbols to be at the head of the list. */ all local symbols to be at the head of the list. */
static INLINE int static int
sym_is_global (bfd *abfd, asymbol *sym) sym_is_global (bfd *abfd, asymbol *sym)
{ {
/* If the backend has a special mapping, use it. */ /* If the backend has a special mapping, use it. */
@ -3028,7 +3028,7 @@ elf_map_symbols (bfd *abfd)
/* Align to the maximum file alignment that could be required for any /* Align to the maximum file alignment that could be required for any
ELF data structure. */ ELF data structure. */
static INLINE file_ptr static inline file_ptr
align_file_position (file_ptr off, int align) align_file_position (file_ptr off, int align)
{ {
return (off + align - 1) & ~(align - 1); return (off + align - 1) & ~(align - 1);

View file

@ -151,31 +151,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define LOG_FILE_ALIGN 2 #define LOG_FILE_ALIGN 2
#endif #endif
/* Static functions */
static void elf_swap_ehdr_in
PARAMS ((bfd *, const Elf_External_Ehdr *, Elf_Internal_Ehdr *));
static void elf_swap_ehdr_out
PARAMS ((bfd *, const Elf_Internal_Ehdr *, Elf_External_Ehdr *));
static void elf_swap_shdr_in
PARAMS ((bfd *, const Elf_External_Shdr *, Elf_Internal_Shdr *));
static void elf_swap_shdr_out
PARAMS ((bfd *, const Elf_Internal_Shdr *, Elf_External_Shdr *));
#define elf_stringtab_init _bfd_elf_stringtab_init #define elf_stringtab_init _bfd_elf_stringtab_init
#define section_from_elf_index bfd_section_from_elf_index #define section_from_elf_index bfd_section_from_elf_index
static bfd_boolean elf_slurp_reloc_table_from_section
PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, bfd_size_type,
arelent *, asymbol **, bfd_boolean));
static bfd_boolean elf_file_p PARAMS ((Elf_External_Ehdr *));
#ifdef DEBUG #ifdef DEBUG
static void elf_debug_section PARAMS ((int, Elf_Internal_Shdr *)); static void elf_debug_section (int, Elf_Internal_Shdr *);
static void elf_debug_file PARAMS ((Elf_Internal_Ehdr *)); static void elf_debug_file (Elf_Internal_Ehdr *);
static char *elf_symbol_flags PARAMS ((flagword)); static char *elf_symbol_flags (flagword);
#endif #endif
/* Structure swapping routines */ /* Structure swapping routines */
@ -199,14 +182,13 @@ static char *elf_symbol_flags PARAMS ((flagword));
format. */ format. */
void void
elf_swap_symbol_in (abfd, psrc, pshn, dst) elf_swap_symbol_in (bfd *abfd,
bfd *abfd; const void *psrc,
const PTR psrc; const void *pshn,
const PTR pshn; Elf_Internal_Sym *dst)
Elf_Internal_Sym *dst;
{ {
const Elf_External_Sym *src = (const Elf_External_Sym *) psrc; const Elf_External_Sym *src = psrc;
const Elf_External_Sym_Shndx *shndx = (const Elf_External_Sym_Shndx *) pshn; const Elf_External_Sym_Shndx *shndx = pshn;
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
dst->st_name = H_GET_32 (abfd, src->st_name); dst->st_name = H_GET_32 (abfd, src->st_name);
@ -230,14 +212,13 @@ elf_swap_symbol_in (abfd, psrc, pshn, dst)
format. */ format. */
void void
elf_swap_symbol_out (abfd, src, cdst, shndx) elf_swap_symbol_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Sym *src,
const Elf_Internal_Sym *src; void *cdst,
PTR cdst; void *shndx)
PTR shndx;
{ {
unsigned int tmp; unsigned int tmp;
Elf_External_Sym *dst = (Elf_External_Sym *) cdst; Elf_External_Sym *dst = cdst;
H_PUT_32 (abfd, src->st_name, dst->st_name); H_PUT_32 (abfd, src->st_name, dst->st_name);
H_PUT_WORD (abfd, src->st_value, dst->st_value); H_PUT_WORD (abfd, src->st_value, dst->st_value);
H_PUT_WORD (abfd, src->st_size, dst->st_size); H_PUT_WORD (abfd, src->st_size, dst->st_size);
@ -258,10 +239,9 @@ elf_swap_symbol_out (abfd, src, cdst, shndx)
internal format. */ internal format. */
static void static void
elf_swap_ehdr_in (abfd, src, dst) elf_swap_ehdr_in (bfd *abfd,
bfd *abfd; const Elf_External_Ehdr *src,
const Elf_External_Ehdr *src; Elf_Internal_Ehdr *dst)
Elf_Internal_Ehdr *dst;
{ {
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
memcpy (dst->e_ident, src->e_ident, EI_NIDENT); memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
@ -287,10 +267,9 @@ elf_swap_ehdr_in (abfd, src, dst)
external format. */ external format. */
static void static void
elf_swap_ehdr_out (abfd, src, dst) elf_swap_ehdr_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Ehdr *src,
const Elf_Internal_Ehdr *src; Elf_External_Ehdr *dst)
Elf_External_Ehdr *dst;
{ {
unsigned int tmp; unsigned int tmp;
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
@ -324,10 +303,9 @@ elf_swap_ehdr_out (abfd, src, dst)
ELF section header table entry in internal format. */ ELF section header table entry in internal format. */
static void static void
elf_swap_shdr_in (abfd, src, dst) elf_swap_shdr_in (bfd *abfd,
bfd *abfd; const Elf_External_Shdr *src,
const Elf_External_Shdr *src; Elf_Internal_Shdr *dst)
Elf_Internal_Shdr *dst;
{ {
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
@ -352,10 +330,9 @@ elf_swap_shdr_in (abfd, src, dst)
ELF section header table entry in external format. */ ELF section header table entry in external format. */
static void static void
elf_swap_shdr_out (abfd, src, dst) elf_swap_shdr_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Shdr *src,
const Elf_Internal_Shdr *src; Elf_External_Shdr *dst)
Elf_External_Shdr *dst;
{ {
/* note that all elements of dst are *arrays of unsigned char* already... */ /* note that all elements of dst are *arrays of unsigned char* already... */
H_PUT_32 (abfd, src->sh_name, dst->sh_name); H_PUT_32 (abfd, src->sh_name, dst->sh_name);
@ -374,10 +351,9 @@ elf_swap_shdr_out (abfd, src, dst)
ELF program header table entry in internal format. */ ELF program header table entry in internal format. */
void void
elf_swap_phdr_in (abfd, src, dst) elf_swap_phdr_in (bfd *abfd,
bfd *abfd; const Elf_External_Phdr *src,
const Elf_External_Phdr *src; Elf_Internal_Phdr *dst)
Elf_Internal_Phdr *dst;
{ {
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
@ -400,10 +376,9 @@ elf_swap_phdr_in (abfd, src, dst)
} }
void void
elf_swap_phdr_out (abfd, src, dst) elf_swap_phdr_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Phdr *src,
const Elf_Internal_Phdr *src; Elf_External_Phdr *dst)
Elf_External_Phdr *dst;
{ {
/* note that all elements of dst are *arrays of unsigned char* already... */ /* note that all elements of dst are *arrays of unsigned char* already... */
H_PUT_32 (abfd, src->p_type, dst->p_type); H_PUT_32 (abfd, src->p_type, dst->p_type);
@ -418,10 +393,9 @@ elf_swap_phdr_out (abfd, src, dst)
/* Translate an ELF reloc from external format to internal format. */ /* Translate an ELF reloc from external format to internal format. */
void void
elf_swap_reloc_in (abfd, s, dst) elf_swap_reloc_in (bfd *abfd,
bfd *abfd; const bfd_byte *s,
const bfd_byte *s; Elf_Internal_Rela *dst)
Elf_Internal_Rela *dst;
{ {
const Elf_External_Rel *src = (const Elf_External_Rel *) s; const Elf_External_Rel *src = (const Elf_External_Rel *) s;
dst->r_offset = H_GET_WORD (abfd, src->r_offset); dst->r_offset = H_GET_WORD (abfd, src->r_offset);
@ -430,10 +404,9 @@ elf_swap_reloc_in (abfd, s, dst)
} }
void void
elf_swap_reloca_in (abfd, s, dst) elf_swap_reloca_in (bfd *abfd,
bfd *abfd; const bfd_byte *s,
const bfd_byte *s; Elf_Internal_Rela *dst)
Elf_Internal_Rela *dst;
{ {
const Elf_External_Rela *src = (const Elf_External_Rela *) s; const Elf_External_Rela *src = (const Elf_External_Rela *) s;
dst->r_offset = H_GET_WORD (abfd, src->r_offset); dst->r_offset = H_GET_WORD (abfd, src->r_offset);
@ -443,10 +416,9 @@ elf_swap_reloca_in (abfd, s, dst)
/* Translate an ELF reloc from internal format to external format. */ /* Translate an ELF reloc from internal format to external format. */
void void
elf_swap_reloc_out (abfd, src, d) elf_swap_reloc_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Rela *src,
const Elf_Internal_Rela *src; bfd_byte *d)
bfd_byte *d;
{ {
Elf_External_Rel *dst = (Elf_External_Rel *) d; Elf_External_Rel *dst = (Elf_External_Rel *) d;
H_PUT_WORD (abfd, src->r_offset, dst->r_offset); H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
@ -454,10 +426,9 @@ elf_swap_reloc_out (abfd, src, d)
} }
void void
elf_swap_reloca_out (abfd, src, d) elf_swap_reloca_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Rela *src,
const Elf_Internal_Rela *src; bfd_byte *d)
bfd_byte *d;
{ {
Elf_External_Rela *dst = (Elf_External_Rela *) d; Elf_External_Rela *dst = (Elf_External_Rela *) d;
H_PUT_WORD (abfd, src->r_offset, dst->r_offset); H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
@ -465,25 +436,23 @@ elf_swap_reloca_out (abfd, src, d)
H_PUT_SIGNED_WORD (abfd, src->r_addend, dst->r_addend); H_PUT_SIGNED_WORD (abfd, src->r_addend, dst->r_addend);
} }
INLINE void void
elf_swap_dyn_in (abfd, p, dst) elf_swap_dyn_in (bfd *abfd,
bfd *abfd; const void *p,
const PTR p; Elf_Internal_Dyn *dst)
Elf_Internal_Dyn *dst;
{ {
const Elf_External_Dyn *src = (const Elf_External_Dyn *) p; const Elf_External_Dyn *src = p;
dst->d_tag = H_GET_WORD (abfd, src->d_tag); dst->d_tag = H_GET_WORD (abfd, src->d_tag);
dst->d_un.d_val = H_GET_WORD (abfd, src->d_un.d_val); dst->d_un.d_val = H_GET_WORD (abfd, src->d_un.d_val);
} }
INLINE void void
elf_swap_dyn_out (abfd, src, p) elf_swap_dyn_out (bfd *abfd,
bfd *abfd; const Elf_Internal_Dyn *src,
const Elf_Internal_Dyn *src; void *p)
PTR p;
{ {
Elf_External_Dyn *dst = (Elf_External_Dyn *) p; Elf_External_Dyn *dst = p;
H_PUT_WORD (abfd, src->d_tag, dst->d_tag); H_PUT_WORD (abfd, src->d_tag, dst->d_tag);
H_PUT_WORD (abfd, src->d_un.d_val, dst->d_un.d_val); H_PUT_WORD (abfd, src->d_un.d_val, dst->d_un.d_val);
@ -496,9 +465,8 @@ elf_swap_dyn_out (abfd, src, p)
First we validate the file by reading in the ELF header and checking First we validate the file by reading in the ELF header and checking
the magic number. */ the magic number. */
static INLINE bfd_boolean static inline bfd_boolean
elf_file_p (x_ehdrp) elf_file_p (Elf_External_Ehdr *x_ehdrp)
Elf_External_Ehdr *x_ehdrp;
{ {
return ((x_ehdrp->e_ident[EI_MAG0] == ELFMAG0) return ((x_ehdrp->e_ident[EI_MAG0] == ELFMAG0)
&& (x_ehdrp->e_ident[EI_MAG1] == ELFMAG1) && (x_ehdrp->e_ident[EI_MAG1] == ELFMAG1)
@ -515,8 +483,7 @@ elf_file_p (x_ehdrp)
file does not match the target vector. */ file does not match the target vector. */
const bfd_target * const bfd_target *
elf_object_p (abfd) elf_object_p (bfd *abfd)
bfd *abfd;
{ {
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */ Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
@ -534,8 +501,7 @@ elf_object_p (abfd)
/* Read in the ELF header in external format. */ /* Read in the ELF header in external format. */
if (bfd_bread ((PTR) & x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd) if (bfd_bread (&x_ehdr, sizeof (x_ehdr), abfd) != sizeof (x_ehdr))
!= sizeof (x_ehdr))
{ {
if (bfd_get_error () != bfd_error_system_call) if (bfd_get_error () != bfd_error_system_call)
goto got_wrong_format_error; goto got_wrong_format_error;
@ -669,8 +635,7 @@ elf_object_p (abfd)
/* Read the first section header at index 0, and convert to internal /* Read the first section header at index 0, and convert to internal
form. */ form. */
if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd) if (bfd_bread (&x_shdr, sizeof x_shdr, abfd) != sizeof (x_shdr))
!= sizeof (x_shdr))
goto got_no_match; goto got_no_match;
elf_swap_shdr_in (abfd, &x_shdr, &i_shdr); elf_swap_shdr_in (abfd, &x_shdr, &i_shdr);
@ -692,7 +657,7 @@ elf_object_p (abfd)
unsigned int num_sec; unsigned int num_sec;
amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum; amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
i_shdrp = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); i_shdrp = bfd_alloc (abfd, amt);
if (!i_shdrp) if (!i_shdrp)
goto got_no_match; goto got_no_match;
num_sec = i_ehdrp->e_shnum; num_sec = i_ehdrp->e_shnum;
@ -700,7 +665,7 @@ elf_object_p (abfd)
num_sec += SHN_HIRESERVE + 1 - SHN_LORESERVE; num_sec += SHN_HIRESERVE + 1 - SHN_LORESERVE;
elf_numsections (abfd) = num_sec; elf_numsections (abfd) = num_sec;
amt = sizeof (i_shdrp) * num_sec; amt = sizeof (i_shdrp) * num_sec;
elf_elfsections (abfd) = (Elf_Internal_Shdr **) bfd_alloc (abfd, amt); elf_elfsections (abfd) = bfd_alloc (abfd, amt);
if (!elf_elfsections (abfd)) if (!elf_elfsections (abfd))
goto got_no_match; goto got_no_match;
@ -721,8 +686,7 @@ elf_object_p (abfd)
to internal form. */ to internal form. */
for (shindex = 1; shindex < i_ehdrp->e_shnum; shindex++) for (shindex = 1; shindex < i_ehdrp->e_shnum; shindex++)
{ {
if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd) if (bfd_bread (&x_shdr, sizeof x_shdr, abfd) != sizeof (x_shdr))
!= sizeof (x_shdr))
goto got_no_match; goto got_no_match;
elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex); elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
@ -753,7 +717,7 @@ elf_object_p (abfd)
unsigned int i; unsigned int i;
amt = i_ehdrp->e_phnum * sizeof (Elf_Internal_Phdr); amt = i_ehdrp->e_phnum * sizeof (Elf_Internal_Phdr);
elf_tdata (abfd)->phdr = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt); elf_tdata (abfd)->phdr = bfd_alloc (abfd, amt);
if (elf_tdata (abfd)->phdr == NULL) if (elf_tdata (abfd)->phdr == NULL)
goto got_no_match; goto got_no_match;
if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0) if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0)
@ -763,8 +727,7 @@ elf_object_p (abfd)
{ {
Elf_External_Phdr x_phdr; Elf_External_Phdr x_phdr;
if (bfd_bread ((PTR) &x_phdr, (bfd_size_type) sizeof x_phdr, abfd) if (bfd_bread (&x_phdr, sizeof x_phdr, abfd) != sizeof x_phdr)
!= sizeof x_phdr)
goto got_no_match; goto got_no_match;
elf_swap_phdr_in (abfd, &x_phdr, i_phdr); elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
} }
@ -850,12 +813,9 @@ elf_object_p (abfd)
/* Write out the relocs. */ /* Write out the relocs. */
void void
elf_write_relocs (abfd, sec, data) elf_write_relocs (bfd *abfd, asection *sec, void *data)
bfd *abfd;
asection *sec;
PTR data;
{ {
bfd_boolean *failedp = (bfd_boolean *) data; bfd_boolean *failedp = data;
Elf_Internal_Shdr *rela_hdr; Elf_Internal_Shdr *rela_hdr;
bfd_vma addr_offset; bfd_vma addr_offset;
void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *)); void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
@ -882,7 +842,7 @@ elf_write_relocs (abfd, sec, data)
rela_hdr = &elf_section_data (sec)->rel_hdr; rela_hdr = &elf_section_data (sec)->rel_hdr;
rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count; rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count;
rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size); rela_hdr->contents = bfd_alloc (abfd, rela_hdr->sh_size);
if (rela_hdr->contents == NULL) if (rela_hdr->contents == NULL)
{ {
*failedp = TRUE; *failedp = TRUE;
@ -960,17 +920,16 @@ elf_write_relocs (abfd, sec, data)
/* Write out the program headers. */ /* Write out the program headers. */
int int
elf_write_out_phdrs (abfd, phdr, count) elf_write_out_phdrs (bfd *abfd,
bfd *abfd; const Elf_Internal_Phdr *phdr,
const Elf_Internal_Phdr *phdr; unsigned int count)
unsigned int count;
{ {
while (count--) while (count--)
{ {
Elf_External_Phdr extphdr; Elf_External_Phdr extphdr;
elf_swap_phdr_out (abfd, phdr, &extphdr); elf_swap_phdr_out (abfd, phdr, &extphdr);
if (bfd_bwrite (&extphdr, (bfd_size_type) sizeof (Elf_External_Phdr), if (bfd_bwrite (&extphdr, sizeof (Elf_External_Phdr), abfd)
abfd) != sizeof (Elf_External_Phdr)) != sizeof (Elf_External_Phdr))
return -1; return -1;
phdr++; phdr++;
} }
@ -980,8 +939,7 @@ elf_write_out_phdrs (abfd, phdr, count)
/* Write out the section headers and the ELF file header. */ /* Write out the section headers and the ELF file header. */
bfd_boolean bfd_boolean
elf_write_shdrs_and_ehdr (abfd) elf_write_shdrs_and_ehdr (bfd *abfd)
bfd *abfd;
{ {
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */ Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
@ -1001,7 +959,7 @@ elf_write_shdrs_and_ehdr (abfd)
elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr); elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr);
amt = sizeof (x_ehdr); amt = sizeof (x_ehdr);
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|| bfd_bwrite ((PTR) & x_ehdr, amt, abfd) != amt) || bfd_bwrite (&x_ehdr, amt, abfd) != amt)
return FALSE; return FALSE;
/* Some fields in the first section header handle overflow of ehdr /* Some fields in the first section header handle overflow of ehdr
@ -1014,7 +972,7 @@ elf_write_shdrs_and_ehdr (abfd)
/* at this point we've concocted all the ELF sections... */ /* at this point we've concocted all the ELF sections... */
amt = i_ehdrp->e_shnum; amt = i_ehdrp->e_shnum;
amt *= sizeof (*x_shdrp); amt *= sizeof (*x_shdrp);
x_shdrp = (Elf_External_Shdr *) bfd_alloc (abfd, amt); x_shdrp = bfd_alloc (abfd, amt);
if (!x_shdrp) if (!x_shdrp)
return FALSE; return FALSE;
@ -1029,7 +987,7 @@ elf_write_shdrs_and_ehdr (abfd)
i_shdrp += SHN_HIRESERVE + 1 - SHN_LORESERVE; i_shdrp += SHN_HIRESERVE + 1 - SHN_LORESERVE;
} }
if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0 if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0
|| bfd_bwrite ((PTR) x_shdrp, amt, abfd) != amt) || bfd_bwrite (x_shdrp, amt, abfd) != amt)
return FALSE; return FALSE;
/* need to dump the string table too... */ /* need to dump the string table too... */
@ -1038,10 +996,7 @@ elf_write_shdrs_and_ehdr (abfd)
} }
long long
elf_slurp_symbol_table (abfd, symptrs, dynamic) elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
bfd *abfd;
asymbol **symptrs; /* Buffer for generated bfd symbols */
bfd_boolean dynamic;
{ {
Elf_Internal_Shdr *hdr; Elf_Internal_Shdr *hdr;
Elf_Internal_Shdr *verhdr; Elf_Internal_Shdr *verhdr;
@ -1101,7 +1056,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic)
amt = symcount; amt = symcount;
amt *= sizeof (elf_symbol_type); amt *= sizeof (elf_symbol_type);
symbase = (elf_symbol_type *) bfd_zalloc (abfd, amt); symbase = bfd_zalloc (abfd, amt);
if (symbase == (elf_symbol_type *) NULL) if (symbase == (elf_symbol_type *) NULL)
goto error_return; goto error_return;
@ -1125,12 +1080,11 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic)
if (bfd_seek (abfd, verhdr->sh_offset, SEEK_SET) != 0) if (bfd_seek (abfd, verhdr->sh_offset, SEEK_SET) != 0)
goto error_return; goto error_return;
xverbuf = (Elf_External_Versym *) bfd_malloc (verhdr->sh_size); xverbuf = bfd_malloc (verhdr->sh_size);
if (xverbuf == NULL && verhdr->sh_size != 0) if (xverbuf == NULL && verhdr->sh_size != 0)
goto error_return; goto error_return;
if (bfd_bread ((PTR) xverbuf, verhdr->sh_size, abfd) if (bfd_bread (xverbuf, verhdr->sh_size, abfd) != verhdr->sh_size)
!= verhdr->sh_size)
goto error_return; goto error_return;
} }
@ -1276,25 +1230,23 @@ error_return:
them. */ them. */
static bfd_boolean static bfd_boolean
elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count, elf_slurp_reloc_table_from_section (bfd *abfd,
relents, symbols, dynamic) asection *asect,
bfd *abfd; Elf_Internal_Shdr *rel_hdr,
asection *asect; bfd_size_type reloc_count,
Elf_Internal_Shdr *rel_hdr; arelent *relents,
bfd_size_type reloc_count; asymbol **symbols,
arelent *relents; bfd_boolean dynamic)
asymbol **symbols;
bfd_boolean dynamic;
{ {
struct elf_backend_data * const ebd = get_elf_backend_data (abfd); struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
PTR allocated = NULL; void *allocated = NULL;
bfd_byte *native_relocs; bfd_byte *native_relocs;
arelent *relent; arelent *relent;
unsigned int i; unsigned int i;
int entsize; int entsize;
unsigned int symcount; unsigned int symcount;
allocated = (PTR) bfd_malloc (rel_hdr->sh_size); allocated = bfd_malloc (rel_hdr->sh_size);
if (allocated == NULL) if (allocated == NULL)
goto error_return; goto error_return;
@ -1303,7 +1255,7 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count,
!= rel_hdr->sh_size)) != rel_hdr->sh_size))
goto error_return; goto error_return;
native_relocs = (bfd_byte *) allocated; native_relocs = allocated;
entsize = rel_hdr->sh_entsize; entsize = rel_hdr->sh_entsize;
BFD_ASSERT (entsize == sizeof (Elf_External_Rel) BFD_ASSERT (entsize == sizeof (Elf_External_Rel)
@ -1381,11 +1333,10 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count,
/* Read in and swap the external relocs. */ /* Read in and swap the external relocs. */
bfd_boolean bfd_boolean
elf_slurp_reloc_table (abfd, asect, symbols, dynamic) elf_slurp_reloc_table (bfd *abfd,
bfd *abfd; asection *asect,
asection *asect; asymbol **symbols,
asymbol **symbols; bfd_boolean dynamic)
bfd_boolean dynamic;
{ {
struct bfd_elf_section_data * const d = elf_section_data (asect); struct bfd_elf_section_data * const d = elf_section_data (asect);
Elf_Internal_Shdr *rel_hdr; Elf_Internal_Shdr *rel_hdr;
@ -1430,7 +1381,7 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
} }
amt = (reloc_count + reloc_count2) * sizeof (arelent); amt = (reloc_count + reloc_count2) * sizeof (arelent);
relents = (arelent *) bfd_alloc (abfd, amt); relents = bfd_alloc (abfd, amt);
if (relents == NULL) if (relents == NULL)
return FALSE; return FALSE;
@ -1453,9 +1404,7 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
#ifdef DEBUG #ifdef DEBUG
static void static void
elf_debug_section (num, hdr) elf_debug_section (int num, Elf_Internal_Shdr *hdr)
int num;
Elf_Internal_Shdr *hdr;
{ {
fprintf (stderr, "\nSection#%d '%s' 0x%.8lx\n", num, fprintf (stderr, "\nSection#%d '%s' 0x%.8lx\n", num,
hdr->bfd_section != NULL ? hdr->bfd_section->name : "", hdr->bfd_section != NULL ? hdr->bfd_section->name : "",
@ -1481,8 +1430,7 @@ elf_debug_section (num, hdr)
} }
static void static void
elf_debug_file (ehdrp) elf_debug_file (Elf_Internal_Ehdr *ehdrp)
Elf_Internal_Ehdr *ehdrp;
{ {
fprintf (stderr, "e_entry = 0x%.8lx\n", (long) ehdrp->e_entry); fprintf (stderr, "e_entry = 0x%.8lx\n", (long) ehdrp->e_entry);
fprintf (stderr, "e_phoff = %ld\n", (long) ehdrp->e_phoff); fprintf (stderr, "e_phoff = %ld\n", (long) ehdrp->e_phoff);
@ -1494,8 +1442,7 @@ elf_debug_file (ehdrp)
} }
static char * static char *
elf_symbol_flags (flags) elf_symbol_flags (flagword flags)
flagword flags;
{ {
static char buffer[1024]; static char buffer[1024];
@ -1580,12 +1527,11 @@ elf_symbol_flags (flags)
remote memory. */ remote memory. */
bfd * bfd *
NAME(_bfd_elf,bfd_from_remote_memory) (templ, ehdr_vma, loadbasep, NAME(_bfd_elf,bfd_from_remote_memory)
target_read_memory) (bfd *templ,
bfd *templ; bfd_vma ehdr_vma,
bfd_vma ehdr_vma; bfd_vma *loadbasep,
bfd_vma *loadbasep; int (*target_read_memory) (bfd_vma, char *, int))
int (*target_read_memory) PARAMS ((bfd_vma vma, char *myaddr, int len));
{ {
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */ Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */
@ -1654,8 +1600,7 @@ NAME(_bfd_elf,bfd_from_remote_memory) (templ, ehdr_vma, loadbasep,
return NULL; return NULL;
} }
x_phdrs = (Elf_External_Phdr *) x_phdrs = bfd_malloc (i_ehdr.e_phnum * (sizeof *x_phdrs + sizeof *i_phdrs));
bfd_malloc (i_ehdr.e_phnum * (sizeof *x_phdrs + sizeof *i_phdrs));
if (x_phdrs == NULL) if (x_phdrs == NULL)
{ {
bfd_set_error (bfd_error_no_memory); bfd_set_error (bfd_error_no_memory);
@ -1716,7 +1661,7 @@ NAME(_bfd_elf,bfd_from_remote_memory) (templ, ehdr_vma, loadbasep,
contents_size = last_phdr->p_offset + last_phdr->p_filesz; contents_size = last_phdr->p_offset + last_phdr->p_filesz;
/* Now we know the size of the whole image we want read in. */ /* Now we know the size of the whole image we want read in. */
contents = (char *) bfd_zmalloc ((bfd_size_type) contents_size); contents = bfd_zmalloc (contents_size);
if (contents == NULL) if (contents == NULL)
{ {
free (x_phdrs); free (x_phdrs);
@ -1761,8 +1706,7 @@ NAME(_bfd_elf,bfd_from_remote_memory) (templ, ehdr_vma, loadbasep,
memcpy (contents, &x_ehdr, sizeof x_ehdr); memcpy (contents, &x_ehdr, sizeof x_ehdr);
/* Now we have a memory image of the ELF file contents. Make a BFD. */ /* Now we have a memory image of the ELF file contents. Make a BFD. */
bim = ((struct bfd_in_memory *) bim = bfd_malloc (sizeof (struct bfd_in_memory));
bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
if (bim == NULL) if (bim == NULL)
{ {
free (contents); free (contents);
@ -1781,7 +1725,7 @@ NAME(_bfd_elf,bfd_from_remote_memory) (templ, ehdr_vma, loadbasep,
nbfd->xvec = templ->xvec; nbfd->xvec = templ->xvec;
bim->size = contents_size; bim->size = contents_size;
bim->buffer = contents; bim->buffer = contents;
nbfd->iostream = (PTR) bim; nbfd->iostream = bim;
nbfd->flags = BFD_IN_MEMORY; nbfd->flags = BFD_IN_MEMORY;
nbfd->direction = read_direction; nbfd->direction = read_direction;
nbfd->mtime = time (NULL); nbfd->mtime = time (NULL);

View file

@ -19,23 +19,19 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
char* char*
elf_core_file_failing_command (abfd) elf_core_file_failing_command (bfd *abfd)
bfd *abfd;
{ {
return elf_tdata (abfd)->core_command; return elf_tdata (abfd)->core_command;
} }
int int
elf_core_file_failing_signal (abfd) elf_core_file_failing_signal (bfd *abfd)
bfd *abfd;
{ {
return elf_tdata (abfd)->core_signal; return elf_tdata (abfd)->core_signal;
} }
bfd_boolean bfd_boolean
elf_core_file_matches_executable_p (core_bfd, exec_bfd) elf_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
bfd *core_bfd;
bfd *exec_bfd;
{ {
char* corename; char* corename;
@ -55,7 +51,7 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd)
execname = execname ? execname + 1 : exec_bfd->filename; execname = execname ? execname + 1 : exec_bfd->filename;
if (strcmp(execname, corename) != 0) if (strcmp (execname, corename) != 0)
return FALSE; return FALSE;
} }
@ -74,8 +70,7 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd)
floating point registers (.reg2). */ floating point registers (.reg2). */
const bfd_target * const bfd_target *
elf_core_file_p (abfd) elf_core_file_p (bfd *abfd)
bfd *abfd;
{ {
Elf_External_Ehdr x_ehdr; /* Elf file header, external form. */ Elf_External_Ehdr x_ehdr; /* Elf file header, external form. */
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form. */ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form. */
@ -88,8 +83,7 @@ elf_core_file_p (abfd)
preserve.marker = NULL; preserve.marker = NULL;
/* Read in the ELF header in external format. */ /* Read in the ELF header in external format. */
if (bfd_bread ((PTR) &x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd) if (bfd_bread (&x_ehdr, sizeof (x_ehdr), abfd) != sizeof (x_ehdr))
!= sizeof (x_ehdr))
{ {
if (bfd_get_error () != bfd_error_system_call) if (bfd_get_error () != bfd_error_system_call)
goto wrong; goto wrong;
@ -193,7 +187,7 @@ elf_core_file_p (abfd)
/* Allocate space for the program headers. */ /* Allocate space for the program headers. */
amt = sizeof (*i_phdrp) * i_ehdrp->e_phnum; amt = sizeof (*i_phdrp) * i_ehdrp->e_phnum;
i_phdrp = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt); i_phdrp = bfd_alloc (abfd, amt);
if (!i_phdrp) if (!i_phdrp)
goto fail; goto fail;
@ -204,8 +198,7 @@ elf_core_file_p (abfd)
{ {
Elf_External_Phdr x_phdr; Elf_External_Phdr x_phdr;
if (bfd_bread ((PTR) &x_phdr, (bfd_size_type) sizeof (x_phdr), abfd) if (bfd_bread (&x_phdr, sizeof (x_phdr), abfd) != sizeof (x_phdr))
!= sizeof (x_phdr))
goto fail; goto fail;
elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex); elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);

View file

@ -25,13 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define ARCH_SIZE 0 #define ARCH_SIZE 0
#include "elf-bfd.h" #include "elf-bfd.h"
static bfd_boolean elf_link_read_relocs_from_section
PARAMS ((bfd *, Elf_Internal_Shdr *, PTR, Elf_Internal_Rela *));
bfd_boolean bfd_boolean
_bfd_elf_create_got_section (abfd, info) _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
bfd *abfd;
struct bfd_link_info *info;
{ {
flagword flags; flagword flags;
asection *s; asection *s;
@ -87,8 +82,7 @@ _bfd_elf_create_got_section (abfd, info)
bh = NULL; bh = NULL;
if (!(_bfd_generic_link_add_one_symbol if (!(_bfd_generic_link_add_one_symbol
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
bed->got_symbol_offset, (const char *) NULL, FALSE, bed->got_symbol_offset, NULL, FALSE, bed->collect, &bh)))
bed->collect, &bh)))
return FALSE; return FALSE;
h = (struct elf_link_hash_entry *) bh; h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
@ -115,9 +109,7 @@ _bfd_elf_create_got_section (abfd, info)
actual contents and size of these sections later. */ actual contents and size of these sections later. */
bfd_boolean bfd_boolean
_bfd_elf_link_create_dynamic_sections (abfd, info) _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
bfd *abfd;
struct bfd_link_info *info;
{ {
flagword flags; flagword flags;
register asection *s; register asection *s;
@ -220,8 +212,8 @@ _bfd_elf_link_create_dynamic_sections (abfd, info)
code examines it to decide how to initialize the process. */ code examines it to decide how to initialize the process. */
bh = NULL; bh = NULL;
if (! (_bfd_generic_link_add_one_symbol if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_DYNAMIC", BSF_GLOBAL, s, (bfd_vma) 0, (info, abfd, "_DYNAMIC", BSF_GLOBAL, s, 0, NULL, FALSE,
(const char *) 0, FALSE, get_elf_backend_data (abfd)->collect, &bh))) get_elf_backend_data (abfd)->collect, &bh)))
return FALSE; return FALSE;
h = (struct elf_link_hash_entry *) bh; h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
@ -252,9 +244,7 @@ _bfd_elf_link_create_dynamic_sections (abfd, info)
/* Create dynamic sections when linking against a dynamic object. */ /* Create dynamic sections when linking against a dynamic object. */
bfd_boolean bfd_boolean
_bfd_elf_create_dynamic_sections (abfd, info) _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
bfd *abfd;
struct bfd_link_info *info;
{ {
flagword flags, pltflags; flagword flags, pltflags;
asection *s; asection *s;
@ -287,9 +277,8 @@ _bfd_elf_create_dynamic_sections (abfd, info)
struct bfd_link_hash_entry *bh = NULL; struct bfd_link_hash_entry *bh = NULL;
if (! (_bfd_generic_link_add_one_symbol if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 0, NULL,
(bfd_vma) 0, (const char *) NULL, FALSE, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
get_elf_backend_data (abfd)->collect, &bh)))
return FALSE; return FALSE;
h = (struct elf_link_hash_entry *) bh; h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
@ -358,9 +347,8 @@ _bfd_elf_create_dynamic_sections (abfd, info)
one. */ one. */
bfd_boolean bfd_boolean
_bfd_elf_link_record_dynamic_symbol (info, h) _bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *info,
struct bfd_link_info *info; struct elf_link_hash_entry *h)
struct elf_link_hash_entry *h;
{ {
if (h->dynindx == -1) if (h->dynindx == -1)
{ {
@ -414,7 +402,7 @@ _bfd_elf_link_record_dynamic_symbol (info, h)
{ {
size_t len = p - name + 1; size_t len = p - name + 1;
alc = bfd_malloc ((bfd_size_type) len); alc = bfd_malloc (len);
if (alc == NULL) if (alc == NULL)
return FALSE; return FALSE;
memcpy (alc, name, len - 1); memcpy (alc, name, len - 1);
@ -440,11 +428,10 @@ _bfd_elf_link_record_dynamic_symbol (info, h)
this in case some dynamic object refers to this symbol. */ this in case some dynamic object refers to this symbol. */
bfd_boolean bfd_boolean
bfd_elf_record_link_assignment (output_bfd, info, name, provide) bfd_elf_record_link_assignment (bfd *output_bfd ATTRIBUTE_UNUSED,
bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info,
struct bfd_link_info *info; const char *name,
const char *name; bfd_boolean provide)
bfd_boolean provide;
{ {
struct elf_link_hash_entry *h; struct elf_link_hash_entry *h;
@ -505,10 +492,9 @@ bfd_elf_record_link_assignment (output_bfd, info, name, provide)
in a discarded section, eg. a discarded link-once section symbol. */ in a discarded section, eg. a discarded link-once section symbol. */
int int
elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx) elf_link_record_local_dynamic_symbol (struct bfd_link_info *info,
struct bfd_link_info *info; bfd *input_bfd,
bfd *input_bfd; long input_indx)
long input_indx;
{ {
bfd_size_type amt; bfd_size_type amt;
struct elf_link_local_dynamic_entry *entry; struct elf_link_local_dynamic_entry *entry;
@ -528,14 +514,13 @@ elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx)
return 1; return 1;
amt = sizeof (*entry); amt = sizeof (*entry);
entry = (struct elf_link_local_dynamic_entry *) bfd_alloc (input_bfd, amt); entry = bfd_alloc (input_bfd, amt);
if (entry == NULL) if (entry == NULL)
return 0; return 0;
/* Go find the symbol, so that we can find it's name. */ /* Go find the symbol, so that we can find it's name. */
if (!bfd_elf_get_elf_syms (input_bfd, &elf_tdata (input_bfd)->symtab_hdr, if (!bfd_elf_get_elf_syms (input_bfd, &elf_tdata (input_bfd)->symtab_hdr,
(size_t) 1, (size_t) input_indx, 1, input_indx, &entry->isym, esym, &eshndx))
&entry->isym, esym, &eshndx))
{ {
bfd_release (input_bfd, entry); bfd_release (input_bfd, entry);
return 0; return 0;
@ -595,10 +580,9 @@ elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx)
/* Return the dynindex of a local dynamic symbol. */ /* Return the dynindex of a local dynamic symbol. */
long long
_bfd_elf_link_lookup_local_dynindx (info, input_bfd, input_indx) _bfd_elf_link_lookup_local_dynindx (struct bfd_link_info *info,
struct bfd_link_info *info; bfd *input_bfd,
bfd *input_bfd; long input_indx)
long input_indx;
{ {
struct elf_link_local_dynamic_entry *e; struct elf_link_local_dynamic_entry *e;
@ -612,15 +596,11 @@ _bfd_elf_link_lookup_local_dynindx (info, input_bfd, input_indx)
them are removed because they are marked as local. This is called them are removed because they are marked as local. This is called
via elf_link_hash_traverse. */ via elf_link_hash_traverse. */
static bfd_boolean elf_link_renumber_hash_table_dynsyms
PARAMS ((struct elf_link_hash_entry *, PTR));
static bfd_boolean static bfd_boolean
elf_link_renumber_hash_table_dynsyms (h, data) elf_link_renumber_hash_table_dynsyms (struct elf_link_hash_entry *h,
struct elf_link_hash_entry *h; void *data)
PTR data;
{ {
size_t *count = (size_t *) data; size_t *count = data;
if (h->root.type == bfd_link_hash_warning) if (h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link; h = (struct elf_link_hash_entry *) h->root.u.i.link;
@ -637,9 +617,7 @@ elf_link_renumber_hash_table_dynsyms (h, data)
the global symbols. */ the global symbols. */
unsigned long unsigned long
_bfd_elf_link_renumber_dynsyms (output_bfd, info) _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, struct bfd_link_info *info)
bfd *output_bfd;
struct bfd_link_info *info;
{ {
unsigned long dynsymcount = 0; unsigned long dynsymcount = 0;
@ -684,20 +662,18 @@ _bfd_elf_link_renumber_dynsyms (output_bfd, info)
a shared object. */ a shared object. */
bfd_boolean bfd_boolean
_bfd_elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, skip, _bfd_elf_merge_symbol (bfd *abfd,
override, type_change_ok, size_change_ok, dt_needed) struct bfd_link_info *info,
bfd *abfd; const char *name,
struct bfd_link_info *info; Elf_Internal_Sym *sym,
const char *name; asection **psec,
Elf_Internal_Sym *sym; bfd_vma *pvalue,
asection **psec; struct elf_link_hash_entry **sym_hash,
bfd_vma *pvalue; bfd_boolean *skip,
struct elf_link_hash_entry **sym_hash; bfd_boolean *override,
bfd_boolean *skip; bfd_boolean *type_change_ok,
bfd_boolean *override; bfd_boolean *size_change_ok,
bfd_boolean *type_change_ok; bfd_boolean dt_needed)
bfd_boolean *size_change_ok;
bfd_boolean dt_needed;
{ {
asection *sec; asection *sec;
struct elf_link_hash_entry *h; struct elf_link_hash_entry *h;
@ -1254,18 +1230,16 @@ _bfd_elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, skip,
indicates if it comes from a DT_NEEDED entry of a shared object. */ indicates if it comes from a DT_NEEDED entry of a shared object. */
bfd_boolean bfd_boolean
_bfd_elf_add_default_symbol (abfd, info, h, name, sym, psec, value, _bfd_elf_add_default_symbol (bfd *abfd,
dynsym, override, dt_needed) struct bfd_link_info *info,
bfd *abfd; struct elf_link_hash_entry *h,
struct bfd_link_info *info; const char *name,
struct elf_link_hash_entry *h; Elf_Internal_Sym *sym,
const char *name; asection **psec,
Elf_Internal_Sym *sym; bfd_vma *value,
asection **psec; bfd_boolean *dynsym,
bfd_vma *value; bfd_boolean override,
bfd_boolean *dynsym; bfd_boolean dt_needed)
bfd_boolean override;
bfd_boolean dt_needed;
{ {
bfd_boolean type_change_ok; bfd_boolean type_change_ok;
bfd_boolean size_change_ok; bfd_boolean size_change_ok;
@ -1337,7 +1311,7 @@ _bfd_elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
bh = &hi->root; bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr, (info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,
(bfd_vma) 0, name, FALSE, collect, &bh))) 0, name, FALSE, collect, &bh)))
return FALSE; return FALSE;
hi = (struct elf_link_hash_entry *) bh; hi = (struct elf_link_hash_entry *) bh;
} }
@ -1461,7 +1435,7 @@ nondefault:
bh = &hi->root; bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT, (info, abfd, shortname, BSF_INDIRECT,
bfd_ind_section_ptr, (bfd_vma) 0, name, FALSE, collect, &bh))) bfd_ind_section_ptr, 0, name, FALSE, collect, &bh)))
return FALSE; return FALSE;
hi = (struct elf_link_hash_entry *) bh; hi = (struct elf_link_hash_entry *) bh;
@ -1507,11 +1481,9 @@ nondefault:
symbol table. It is called via elf_link_hash_traverse. */ symbol table. It is called via elf_link_hash_traverse. */
bfd_boolean bfd_boolean
_bfd_elf_export_symbol (h, data) _bfd_elf_export_symbol (struct elf_link_hash_entry *h, void *data)
struct elf_link_hash_entry *h;
PTR data;
{ {
struct elf_info_failed *eif = (struct elf_info_failed *) data; struct elf_info_failed *eif = data;
/* Ignore indirect symbols. These are added by the versioning code. */ /* Ignore indirect symbols. These are added by the versioning code. */
if (h->root.type == bfd_link_hash_indirect) if (h->root.type == bfd_link_hash_indirect)
@ -1568,11 +1540,10 @@ _bfd_elf_export_symbol (h, data)
This function is called via elf_link_hash_traverse. */ This function is called via elf_link_hash_traverse. */
bfd_boolean bfd_boolean
_bfd_elf_link_find_version_dependencies (h, data) _bfd_elf_link_find_version_dependencies (struct elf_link_hash_entry *h,
struct elf_link_hash_entry *h; void *data)
PTR data;
{ {
struct elf_find_verdep_info *rinfo = (struct elf_find_verdep_info *) data; struct elf_find_verdep_info *rinfo = data;
Elf_Internal_Verneed *t; Elf_Internal_Verneed *t;
Elf_Internal_Vernaux *a; Elf_Internal_Vernaux *a;
bfd_size_type amt; bfd_size_type amt;
@ -1606,7 +1577,7 @@ _bfd_elf_link_find_version_dependencies (h, data)
if (t == NULL) if (t == NULL)
{ {
amt = sizeof *t; amt = sizeof *t;
t = (Elf_Internal_Verneed *) bfd_zalloc (rinfo->output_bfd, amt); t = bfd_zalloc (rinfo->output_bfd, amt);
if (t == NULL) if (t == NULL)
{ {
rinfo->failed = TRUE; rinfo->failed = TRUE;
@ -1619,7 +1590,7 @@ _bfd_elf_link_find_version_dependencies (h, data)
} }
amt = sizeof *a; amt = sizeof *a;
a = (Elf_Internal_Vernaux *) bfd_zalloc (rinfo->output_bfd, amt); a = bfd_zalloc (rinfo->output_bfd, amt);
/* Note that we are copying a string pointer here, and testing it /* Note that we are copying a string pointer here, and testing it
above. If bfd_elf_string_from_elf_section is ever changed to above. If bfd_elf_string_from_elf_section is ever changed to
@ -1646,9 +1617,7 @@ _bfd_elf_link_find_version_dependencies (h, data)
local. This function is called via elf_link_hash_traverse. */ local. This function is called via elf_link_hash_traverse. */
bfd_boolean bfd_boolean
_bfd_elf_link_assign_sym_version (h, data) _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data)
struct elf_link_hash_entry *h;
PTR data;
{ {
struct elf_assign_sym_version_info *sinfo; struct elf_assign_sym_version_info *sinfo;
struct bfd_link_info *info; struct bfd_link_info *info;
@ -1657,7 +1626,7 @@ _bfd_elf_link_assign_sym_version (h, data)
char *p; char *p;
bfd_size_type amt; bfd_size_type amt;
sinfo = (struct elf_assign_sym_version_info *) data; sinfo = data;
info = sinfo->info; info = sinfo->info;
if (h->root.type == bfd_link_hash_warning) if (h->root.type == bfd_link_hash_warning)
@ -1714,7 +1683,7 @@ _bfd_elf_link_assign_sym_version (h, data)
struct bfd_elf_version_expr *d; struct bfd_elf_version_expr *d;
len = p - h->root.root.string; len = p - h->root.root.string;
alc = bfd_malloc ((bfd_size_type) len); alc = bfd_malloc (len);
if (alc == NULL) if (alc == NULL)
return FALSE; return FALSE;
memcpy (alc, h->root.root.string, len - 1); memcpy (alc, h->root.root.string, len - 1);
@ -1771,8 +1740,7 @@ _bfd_elf_link_assign_sym_version (h, data)
return TRUE; return TRUE;
amt = sizeof *t; amt = sizeof *t;
t = ((struct bfd_elf_version_tree *) t = bfd_alloc (sinfo->output_bfd, amt);
bfd_alloc (sinfo->output_bfd, amt));
if (t == NULL) if (t == NULL)
{ {
sinfo->failed = TRUE; sinfo->failed = TRUE;
@ -1906,15 +1874,13 @@ _bfd_elf_link_assign_sym_version (h, data)
Returns FALSE if something goes wrong. */ Returns FALSE if something goes wrong. */
static bfd_boolean static bfd_boolean
elf_link_read_relocs_from_section (abfd, shdr, external_relocs, elf_link_read_relocs_from_section (bfd *abfd,
internal_relocs) Elf_Internal_Shdr *shdr,
bfd *abfd; void *external_relocs,
Elf_Internal_Shdr *shdr; Elf_Internal_Rela *internal_relocs)
PTR external_relocs;
Elf_Internal_Rela *internal_relocs;
{ {
struct elf_backend_data *bed; struct elf_backend_data *bed;
void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *)); void (*swap_in) (bfd *, const bfd_byte *, Elf_Internal_Rela *);
const bfd_byte *erela; const bfd_byte *erela;
const bfd_byte *erelaend; const bfd_byte *erelaend;
Elf_Internal_Rela *irela; Elf_Internal_Rela *irela;
@ -1968,16 +1934,14 @@ elf_link_read_relocs_from_section (abfd, shdr, external_relocs,
REL_HDR2 relocations. */ REL_HDR2 relocations. */
Elf_Internal_Rela * Elf_Internal_Rela *
_bfd_elf_link_read_relocs (abfd, o, external_relocs, internal_relocs, _bfd_elf_link_read_relocs (bfd *abfd,
keep_memory) asection *o,
bfd *abfd; void *external_relocs,
asection *o; Elf_Internal_Rela *internal_relocs,
PTR external_relocs; bfd_boolean keep_memory)
Elf_Internal_Rela *internal_relocs;
bfd_boolean keep_memory;
{ {
Elf_Internal_Shdr *rel_hdr; Elf_Internal_Shdr *rel_hdr;
PTR alloc1 = NULL; void *alloc1 = NULL;
Elf_Internal_Rela *alloc2 = NULL; Elf_Internal_Rela *alloc2 = NULL;
struct elf_backend_data *bed = get_elf_backend_data (abfd); struct elf_backend_data *bed = get_elf_backend_data (abfd);
@ -1996,9 +1960,9 @@ _bfd_elf_link_read_relocs (abfd, o, external_relocs, internal_relocs,
size = o->reloc_count; size = o->reloc_count;
size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela); size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
if (keep_memory) if (keep_memory)
internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size); internal_relocs = bfd_alloc (abfd, size);
else else
internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_malloc (size); internal_relocs = alloc2 = bfd_malloc (size);
if (internal_relocs == NULL) if (internal_relocs == NULL)
goto error_return; goto error_return;
} }
@ -2009,7 +1973,7 @@ _bfd_elf_link_read_relocs (abfd, o, external_relocs, internal_relocs,
if (elf_section_data (o)->rel_hdr2) if (elf_section_data (o)->rel_hdr2)
size += elf_section_data (o)->rel_hdr2->sh_size; size += elf_section_data (o)->rel_hdr2->sh_size;
alloc1 = (PTR) bfd_malloc (size); alloc1 = bfd_malloc (size);
if (alloc1 == NULL) if (alloc1 == NULL)
goto error_return; goto error_return;
external_relocs = alloc1; external_relocs = alloc1;
@ -2051,10 +2015,9 @@ _bfd_elf_link_read_relocs (abfd, o, external_relocs, internal_relocs,
section header for a section containing relocations for O. */ section header for a section containing relocations for O. */
bfd_boolean bfd_boolean
_bfd_elf_link_size_reloc_section (abfd, rel_hdr, o) _bfd_elf_link_size_reloc_section (bfd *abfd,
bfd *abfd; Elf_Internal_Shdr *rel_hdr,
Elf_Internal_Shdr *rel_hdr; asection *o)
asection *o;
{ {
bfd_size_type reloc_count; bfd_size_type reloc_count;
bfd_size_type num_rel_hashes; bfd_size_type num_rel_hashes;
@ -2076,7 +2039,7 @@ _bfd_elf_link_size_reloc_section (abfd, rel_hdr, o)
allocate it with bfd_alloc rather than malloc. Also since we allocate it with bfd_alloc rather than malloc. Also since we
cannot be sure that the contents will actually be filled in, cannot be sure that the contents will actually be filled in,
we zero the allocated space. */ we zero the allocated space. */
rel_hdr->contents = (PTR) bfd_zalloc (abfd, rel_hdr->sh_size); rel_hdr->contents = bfd_zalloc (abfd, rel_hdr->sh_size);
if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0) if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
return FALSE; return FALSE;
@ -2087,9 +2050,7 @@ _bfd_elf_link_size_reloc_section (abfd, rel_hdr, o)
{ {
struct elf_link_hash_entry **p; struct elf_link_hash_entry **p;
p = ((struct elf_link_hash_entry **) p = bfd_zmalloc (num_rel_hashes * sizeof (struct elf_link_hash_entry *));
bfd_zmalloc (num_rel_hashes
* sizeof (struct elf_link_hash_entry *)));
if (p == NULL) if (p == NULL)
return FALSE; return FALSE;
@ -2104,12 +2065,10 @@ _bfd_elf_link_size_reloc_section (abfd, rel_hdr, o)
OUTPUT_BFD. */ OUTPUT_BFD. */
bfd_boolean bfd_boolean
_bfd_elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, _bfd_elf_link_output_relocs (bfd *output_bfd,
internal_relocs) asection *input_section,
bfd *output_bfd; Elf_Internal_Shdr *input_rel_hdr,
asection *input_section; Elf_Internal_Rela *internal_relocs)
Elf_Internal_Shdr *input_rel_hdr;
Elf_Internal_Rela *internal_relocs;
{ {
Elf_Internal_Rela *irela; Elf_Internal_Rela *irela;
Elf_Internal_Rela *irelaend; Elf_Internal_Rela *irelaend;
@ -2118,7 +2077,7 @@ _bfd_elf_link_output_relocs (output_bfd, input_section, input_rel_hdr,
asection *output_section; asection *output_section;
unsigned int *rel_countp = NULL; unsigned int *rel_countp = NULL;
struct elf_backend_data *bed; struct elf_backend_data *bed;
void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *)); void (*swap_out) (bfd *, const Elf_Internal_Rela *, bfd_byte *);
output_section = input_section->output_section; output_section = input_section->output_section;
output_rel_hdr = NULL; output_rel_hdr = NULL;
@ -2181,9 +2140,8 @@ _bfd_elf_link_output_relocs (output_bfd, input_section, input_rel_hdr,
the face of future changes. */ the face of future changes. */
bfd_boolean bfd_boolean
_bfd_elf_fix_symbol_flags (h, eif) _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h,
struct elf_link_hash_entry *h; struct elf_info_failed *eif)
struct elf_info_failed *eif;
{ {
/* If this symbol was mentioned in a non-ELF file, try to set /* If this symbol was mentioned in a non-ELF file, try to set
DEF_REGULAR and REF_REGULAR correctly. This is the only way to DEF_REGULAR and REF_REGULAR correctly. This is the only way to
@ -2324,11 +2282,9 @@ _bfd_elf_fix_symbol_flags (h, eif)
recursively. */ recursively. */
bfd_boolean bfd_boolean
_bfd_elf_adjust_dynamic_symbol (h, data) _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data)
struct elf_link_hash_entry *h;
PTR data;
{ {
struct elf_info_failed *eif = (struct elf_info_failed *) data; struct elf_info_failed *eif = data;
bfd *dynobj; bfd *dynobj;
struct elf_backend_data *bed; struct elf_backend_data *bed;
@ -2418,7 +2374,7 @@ _bfd_elf_adjust_dynamic_symbol (h, data)
H->WEAKDEF before it finds H? */ H->WEAKDEF before it finds H? */
h->weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR; h->weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
if (! _bfd_elf_adjust_dynamic_symbol (h->weakdef, (PTR) eif)) if (! _bfd_elf_adjust_dynamic_symbol (h->weakdef, eif))
return FALSE; return FALSE;
} }
@ -2449,9 +2405,7 @@ _bfd_elf_adjust_dynamic_symbol (h, data)
to reflect the object merging within the sections. */ to reflect the object merging within the sections. */
bfd_boolean bfd_boolean
_bfd_elf_link_sec_merge_syms (h, data) _bfd_elf_link_sec_merge_syms (struct elf_link_hash_entry *h, void *data)
struct elf_link_hash_entry *h;
PTR data;
{ {
asection *sec; asection *sec;
@ -2463,13 +2417,13 @@ _bfd_elf_link_sec_merge_syms (h, data)
&& ((sec = h->root.u.def.section)->flags & SEC_MERGE) && ((sec = h->root.u.def.section)->flags & SEC_MERGE)
&& sec->sec_info_type == ELF_INFO_TYPE_MERGE) && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
{ {
bfd *output_bfd = (bfd *) data; bfd *output_bfd = data;
h->root.u.def.value = h->root.u.def.value =
_bfd_merged_section_offset (output_bfd, _bfd_merged_section_offset (output_bfd,
&h->root.u.def.section, &h->root.u.def.section,
elf_section_data (sec)->sec_info, elf_section_data (sec)->sec_info,
h->root.u.def.value, (bfd_vma) 0); h->root.u.def.value, 0);
} }
return TRUE; return TRUE;
@ -2480,10 +2434,9 @@ _bfd_elf_link_sec_merge_syms (h, data)
considered to bind dynamically. */ considered to bind dynamically. */
bfd_boolean bfd_boolean
_bfd_elf_dynamic_symbol_p (h, info, ignore_protected) _bfd_elf_dynamic_symbol_p (struct elf_link_hash_entry *h,
struct elf_link_hash_entry *h; struct bfd_link_info *info,
struct bfd_link_info *info; bfd_boolean ignore_protected)
bfd_boolean ignore_protected;
{ {
bfd_boolean binding_stays_local_p; bfd_boolean binding_stays_local_p;
@ -2537,10 +2490,9 @@ _bfd_elf_dynamic_symbol_p (h, info, ignore_protected)
undefined symbols and weak symbols. */ undefined symbols and weak symbols. */
bfd_boolean bfd_boolean
_bfd_elf_symbol_refs_local_p (h, info, local_protected) _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
struct elf_link_hash_entry *h; struct bfd_link_info *info,
struct bfd_link_info *info; bfd_boolean local_protected)
bfd_boolean local_protected;
{ {
/* If it's a local sym, of course we resolve locally. */ /* If it's a local sym, of course we resolve locally. */
if (h == NULL) if (h == NULL)

File diff suppressed because it is too large Load diff