From 86dc0f79f59480ef98f870c71d2e38ea23e56a04 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 18 Nov 1999 01:06:45 +0000 Subject: * elf-bfd.h (struct elf_backend_data): Reorder collect and type_change_ok; add sign_extend_vma. * elf32-mips.c (elf_backend_sign_extend_vma): Define. * elfcode.h (elf_swap_symbol_in): Mind be->sign_extend_vma. (elf_swap_shdr_in, elf_swap_phdr_in): Likewise. * elfxx-target.h (elf_backend_sign_extend_vma): Default. (elfNN_bed): Follow struture changes. --- bfd/elfcode.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'bfd/elfcode.h') diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 1f75fb0..c5edf9b 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -207,8 +207,13 @@ elf_swap_symbol_in (abfd, src, dst) const Elf_External_Sym *src; Elf_Internal_Sym *dst; { + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; + dst->st_name = bfd_h_get_32 (abfd, (bfd_byte *) src->st_name); - dst->st_value = get_word (abfd, (bfd_byte *) src->st_value); + if (signed_vma) + dst->st_value = get_signed_word (abfd, (bfd_byte *) src->st_value); + else + dst->st_value = get_word (abfd, (bfd_byte *) src->st_value); dst->st_size = get_word (abfd, (bfd_byte *) src->st_size); dst->st_info = bfd_h_get_8 (abfd, (bfd_byte *) src->st_info); dst->st_other = bfd_h_get_8 (abfd, (bfd_byte *) src->st_other); @@ -295,10 +300,15 @@ elf_swap_shdr_in (abfd, src, dst) const Elf_External_Shdr *src; Elf_Internal_Shdr *dst; { + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; + dst->sh_name = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_name); dst->sh_type = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_type); dst->sh_flags = get_word (abfd, (bfd_byte *) src->sh_flags); - dst->sh_addr = get_word (abfd, (bfd_byte *) src->sh_addr); + if (signed_vma) + dst->sh_addr = get_signed_word (abfd, (bfd_byte *) src->sh_addr); + else + dst->sh_addr = get_word (abfd, (bfd_byte *) src->sh_addr); dst->sh_offset = get_word (abfd, (bfd_byte *) src->sh_offset); dst->sh_size = get_word (abfd, (bfd_byte *) src->sh_size); dst->sh_link = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_link); @@ -341,11 +351,21 @@ elf_swap_phdr_in (abfd, src, dst) const Elf_External_Phdr *src; Elf_Internal_Phdr *dst; { + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; + dst->p_type = bfd_h_get_32 (abfd, (bfd_byte *) src->p_type); dst->p_flags = bfd_h_get_32 (abfd, (bfd_byte *) src->p_flags); dst->p_offset = get_word (abfd, (bfd_byte *) src->p_offset); - dst->p_vaddr = get_word (abfd, (bfd_byte *) src->p_vaddr); - dst->p_paddr = get_word (abfd, (bfd_byte *) src->p_paddr); + if (signed_vma) + { + dst->p_vaddr = get_signed_word (abfd, (bfd_byte *) src->p_vaddr); + dst->p_paddr = get_signed_word (abfd, (bfd_byte *) src->p_paddr); + } + else + { + dst->p_vaddr = get_word (abfd, (bfd_byte *) src->p_vaddr); + dst->p_paddr = get_word (abfd, (bfd_byte *) src->p_paddr); + } dst->p_filesz = get_word (abfd, (bfd_byte *) src->p_filesz); dst->p_memsz = get_word (abfd, (bfd_byte *) src->p_memsz); dst->p_align = get_word (abfd, (bfd_byte *) src->p_align); -- cgit v1.1