diff options
author | Nick Clifton <nickc@redhat.com> | 2000-01-27 20:05:32 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2000-01-27 20:05:32 +0000 |
commit | 2f0ca46a499086b1c438f5b1768f383fa60351e2 (patch) | |
tree | 88517aeb7b941a0f8137cb60cfbbd1268941aab6 | |
parent | fa3061313cf6689dc5c4df66d29fe56209c689e0 (diff) | |
download | gdb-2f0ca46a499086b1c438f5b1768f383fa60351e2.zip gdb-2f0ca46a499086b1c438f5b1768f383fa60351e2.tar.gz gdb-2f0ca46a499086b1c438f5b1768f383fa60351e2.tar.bz2 |
Apply Thoams de Lellis's patch to fic disassembly of Thumb instructions when
bounded by non-function labels.
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf32-arm.h | 27 | ||||
-rw-r--r-- | gas/ChangeLog | 7 | ||||
-rw-r--r-- | gas/config/tc-arm.c | 12 | ||||
-rw-r--r-- | include/elf/ChangeLog | 6 | ||||
-rw-r--r-- | include/elf/arm.h | 23 | ||||
-rw-r--r-- | opcodes/ChangeLog | 7 | ||||
-rw-r--r-- | opcodes/arm-dis.c | 24 |
8 files changed, 80 insertions, 33 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6a08870..9d7c9f6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2000-01-27 Thomas de Lellis <tdel@wrs.com> + + * elf32-arm.h (elf32_arm_get_symbol_type): If a symbol has the + STT_ARM_16BIT flag set, but it is not attached to a data object + return STT_ARM_16BIT so that it will be treated as code by the + disassembler. + 2000-01-27 Alan Modra <alan@spri.levels.unisa.edu.au> * coff-i386.c (i3coff_object_p): Remove prototype. diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index 6efc7c8..7b78fd6 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -714,7 +714,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) { case R_ARM_PC24: /* This one is a call from arm code. We need to look up - the target of the call. If it is a thumb target, we + the target of the call. If it is a thumb target, we insert glue. */ if (ELF_ST_TYPE(h->type) == STT_ARM_TFUNC) @@ -723,7 +723,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) case R_ARM_THM_PC22: /* This one is a call from thumb code. We look - up the target of the call. If it is not a thumb + up the target of the call. If it is not a thumb target, we insert glue. */ if (ELF_ST_TYPE (h->type) != STT_ARM_TFUNC) @@ -737,6 +737,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) } return true; + error_return: if (free_relocs != NULL) free (free_relocs); @@ -744,8 +745,8 @@ error_return: free (free_contents); if (free_extsyms != NULL) free (free_extsyms); + return false; - } /* The thumb form of a long branch is a bit finicky, because the offset @@ -2103,10 +2104,22 @@ elf32_arm_get_symbol_type (elf_sym, type) Elf_Internal_Sym * elf_sym; int type; { - if (ELF_ST_TYPE (elf_sym->st_info) == STT_ARM_TFUNC) - return ELF_ST_TYPE (elf_sym->st_info); - else - return type; + switch (ELF_ST_TYPE (elf_sym->st_info)) + { + case STT_ARM_TFUNC: + return ELF_ST_TYPE (elf_sym->st_info); + break; + case STT_ARM_16BIT: + /* If the symbol is not an object, return the STT_ARM_16BIT flag. + This allows us to distinguish between data used by Thumb instructions + and non-data (which is probably code) inside Thumb regions of an + executable. */ + if (type != STT_OBJECT) + return ELF_ST_TYPE (elf_sym->st_info); + break; + } + + return type; } static asection * diff --git a/gas/ChangeLog b/gas/ChangeLog index 9ec7fa7..324a2e6 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2000-01-27 Thomas de Lellis <tdel@windriver.com> + + * config/tc-arm.c (armadjust_symtab): If the assembler is in + Thumb mode but the label seen was not declared as '.thumb_func' + then set the ST_INFO type to STT_ARM_16BIT mode. This allows + correct disassembly of Thumb code bounded by non function labels. + 2000-01-27 Alan Modra <alan@spri.levels.unisa.edu.au> * Makefile.am (MULTI_CFILES): Add config/e-i386aout.c diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 19ead2e..31ab321 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -6888,12 +6888,14 @@ arm_adjust_symtab () { if (ARM_IS_THUMB (sym)) { + elf_sym = elf_symbol (symbol_get_bfdsym (sym)); + bind = ELF_ST_BIND (elf_sym); + + /* If it's a .thumb_func, declare it as so, else tag label as .code 16. */ if (THUMB_IS_FUNC (sym)) - { - elf_sym = elf_symbol (symbol_get_bfdsym (sym)); - bind = ELF_ST_BIND (elf_sym); - elf_sym->internal_elf_sym.st_info = ELF_ST_INFO (bind, STT_ARM_TFUNC); - } + elf_sym->internal_elf_sym.st_info = ELF_ST_INFO (bind, STT_ARM_TFUNC); + else + elf_sym->internal_elf_sym.st_info = ELF_ST_INFO (bind, STT_ARM_16BIT); } } #endif diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index d3d7dc0..c8d4fbc 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,9 @@ +2000-01-27 Thomas de Lellis <tdel@windriver.com> + + * arm.h (STT_ARM_TFUNC): Define in terms of STT_LOPROC. + (STT_ARM_16BIT): New flag. Denotes a label that was defined in + Thumb block but was does not identify a function. + 2000-01-20 Nick Clifton <nickc@cygnus.com> * common.h (EM_MCORE): Fix spelling of Motorola. diff --git a/include/elf/arm.h b/include/elf/arm.h index 82c1698..4d3405d 100644 --- a/include/elf/arm.h +++ b/include/elf/arm.h @@ -1,5 +1,5 @@ /* ARM ELF support for BFD. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -29,7 +29,7 @@ #define EF_APCS_26 0x08 #define EF_APCS_FLOAT 0x10 #define EF_PIC 0x20 -#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use. */ #define EF_NEW_ABI 0x80 #define EF_OLD_ABI 0x100 #define EF_SOFT_FLOAT 0x200 @@ -41,15 +41,16 @@ #define F_PIC EF_PIC #define F_SOFT_FLOAT EF_SOFT_FLOAT -/* Additional symbol types for Thumb */ -#define STT_ARM_TFUNC 0xd +/* Additional symbol types for Thumb. */ +#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ +#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ -/* ARM-specific values for sh_flags */ -#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point */ -#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step */ +/* ARM-specific values for sh_flags. */ +#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point. */ +#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step. */ -/* ARM-specific program header flags */ -#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base */ +/* ARM-specific program header flags. */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base. */ /* Relocation types. */ START_RELOC_NUMBERS (elf_arm_reloc_type) @@ -82,8 +83,8 @@ START_RELOC_NUMBERS (elf_arm_reloc_type) FAKE_RELOC (LAST_INVALID_RELOC1, 99) RELOC_NUMBER (R_ARM_GNU_VTENTRY, 100) RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 101) - RELOC_NUMBER (R_ARM_THM_PC11, 102) /* cygnus extension to abi: thumb unconditional branch */ - RELOC_NUMBER (R_ARM_THM_PC9, 103) /* cygnus extension to abi: thumb conditional branch */ + RELOC_NUMBER (R_ARM_THM_PC11, 102) /* Cygnus extension to abi: Thumb unconditional branch */ + RELOC_NUMBER (R_ARM_THM_PC9, 103) /* Cygnus extension to abi: Thumb conditional branch */ FAKE_RELOC (FIRST_INVALID_RELOC2, 104) FAKE_RELOC (LAST_INVALID_RELOC2, 248) RELOC_NUMBER (R_ARM_RXPC25, 249) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index b0a526b..9802397 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2000-01-27 Thomas de Lellis <tdel@windriver.com> + + * arm-dis.c (printf_insn_big_arm): Treat ELF symbols with the + ARM_STT_16BIT flag as Thumb code symbols. + + * arm-dis.c (printf_insn_little_arm): Ditto. + 2000-01-25 Thomas de Lellis <tdel@windriver.com> * arm-dis.c (printf_insn_thumb): Prevent double dumping diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c index fe662ed..959e023 100644 --- a/opcodes/arm-dis.c +++ b/opcodes/arm-dis.c @@ -871,15 +871,13 @@ print_insn_big_arm (pc, info) unsigned char b[4]; long given; int status; - coff_symbol_type * cs; - elf_symbol_type * es; int is_thumb; if (info->disassembler_options) { parse_disassembler_options (info->disassembler_options); - /* To avoid repeated parsing of this option, we remove it here. */ + /* To avoid repeated parsing of the options, we remove it here. */ info->disassembler_options = NULL; } @@ -889,6 +887,8 @@ print_insn_big_arm (pc, info) { if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour) { + coff_symbol_type * cs; + cs = coffsymbol (*info->symbols); is_thumb = ( cs->native->u.syment.n_sclass == C_THUMBEXT || cs->native->u.syment.n_sclass == C_THUMBSTAT @@ -898,9 +898,11 @@ print_insn_big_arm (pc, info) } else if (bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour) { + elf_symbol_type * es; + es = *(elf_symbol_type **)(info->symbols); - is_thumb = ELF_ST_TYPE (es->internal_elf_sym.st_info) == - STT_ARM_TFUNC; + is_thumb = (ELF_ST_TYPE (es->internal_elf_sym.st_info) == STT_ARM_TFUNC) + || (ELF_ST_TYPE (es->internal_elf_sym.st_info) == STT_ARM_16BIT); } } @@ -953,15 +955,13 @@ print_insn_little_arm (pc, info) unsigned char b[4]; long given; int status; - coff_symbol_type * cs; - elf_symbol_type * es; int is_thumb; if (info->disassembler_options) { parse_disassembler_options (info->disassembler_options); - /* To avoid repeated parsing of this option, we remove it here. */ + /* To avoid repeated parsing of the options, we remove it here. */ info->disassembler_options = NULL; } @@ -971,6 +971,8 @@ print_insn_little_arm (pc, info) { if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour) { + coff_symbol_type * cs; + cs = coffsymbol (*info->symbols); is_thumb = ( cs->native->u.syment.n_sclass == C_THUMBEXT || cs->native->u.syment.n_sclass == C_THUMBSTAT @@ -980,9 +982,11 @@ print_insn_little_arm (pc, info) } else if (bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour) { + elf_symbol_type * es; + es = *(elf_symbol_type **)(info->symbols); - is_thumb = ELF_ST_TYPE (es->internal_elf_sym.st_info) == - STT_ARM_TFUNC; + is_thumb = (ELF_ST_TYPE (es->internal_elf_sym.st_info) == STT_ARM_TFUNC) + || (ELF_ST_TYPE (es->internal_elf_sym.st_info) == STT_ARM_16BIT); } } |