From 082fc60dfca102f95d73f123f43060f3f34c0ff6 Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Wed, 6 Feb 2002 15:21:17 +0000 Subject: [PATCH] * arm-tdep.c: Include elf-bfd.h and coff/internal.h. (MSYMBOL_SET_SPECIAL, MSYMBOL_IS_SPECIAL, MSYMBOL_SIZE): Move defines to here from config/tm-arm.h. (coff_sym_is_thumb): Make static. (arm_elf_make_msymbol_special): New function. (arm_coff_make_msymbol_special): New function. * config/arm/tm-arm.h (MSYMBOL_SET_SPECIAL): Delete definition. (MSYMBOL_IS_SPECIAL, MSYMBOL_SIZE): Likewise. (coff_sym_is_thumb): Delete declaration. (arm_elf_make_msymbol_special): Declare. (arm_coff_make_msymbol_special): Declare. (ELF_MAKE_MSYMBOL_SPECIAL): Call arm_elf_make_msymbol_special. (COFF_MAKE_MSYMBOL_SPECIAL): Call arm_coff_make_msymbol_special. --- gdb/ChangeLog | 16 +++++++++ gdb/arm-tdep.c | 74 +++++++++++++++++++++++++++++++++-------- gdb/config/arm/tm-arm.h | 46 ++++++------------------- 3 files changed, 86 insertions(+), 50 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f74e8e146fa..898d48a8327 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2002-02-06 Richard Earnshaw + + * arm-tdep.c: Include elf-bfd.h and coff/internal.h. + (MSYMBOL_SET_SPECIAL, MSYMBOL_IS_SPECIAL, MSYMBOL_SIZE): Move defines + to here from config/tm-arm.h. + (coff_sym_is_thumb): Make static. + (arm_elf_make_msymbol_special): New function. + (arm_coff_make_msymbol_special): New function. + * config/arm/tm-arm.h (MSYMBOL_SET_SPECIAL): Delete definition. + (MSYMBOL_IS_SPECIAL, MSYMBOL_SIZE): Likewise. + (coff_sym_is_thumb): Delete declaration. + (arm_elf_make_msymbol_special): Declare. + (arm_coff_make_msymbol_special): Declare. + (ELF_MAKE_MSYMBOL_SPECIAL): Call arm_elf_make_msymbol_special. + (COFF_MAKE_MSYMBOL_SPECIAL): Call arm_coff_make_msymbol_special. + 2002-02-06 Richard Earnshaw * arm-tdep.c (arm_software_single_step): ANSIfy function declaration. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 1726dad6485..3228842399c 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -33,6 +33,8 @@ #include "doublest.h" #include "value.h" #include "solib-svr4.h" +#include "elf-bfd.h" +#include "coff/internal.h" /* Each OS has a different mechanism for accessing the various registers stored in the sigcontext structure. @@ -64,7 +66,27 @@ #define SIGCONTEXT_REGISTER_ADDRESS_P() 0 #endif -extern void _initialize_arm_tdep (void); +/* Macros for setting and testing a bit in a minimal symbol that marks + it as Thumb function. The MSB of the minimal symbol's "info" field + is used for this purpose. This field is already being used to store + the symbol size, so the assumption is that the symbol size cannot + exceed 2^31. + + MSYMBOL_SET_SPECIAL Actually sets the "special" bit. + MSYMBOL_IS_SPECIAL Tests the "special" bit in a minimal symbol. + MSYMBOL_SIZE Returns the size of the minimal symbol, + i.e. the "info" field with the "special" bit + masked out. */ + +#define MSYMBOL_SET_SPECIAL(msym) \ + MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) \ + | 0x80000000) + +#define MSYMBOL_IS_SPECIAL(msym) \ + (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0) + +#define MSYMBOL_SIZE(msym) \ + ((long) MSYMBOL_INFO (msym) & 0x7fffffff) /* Number of different reg name sets (options). */ static int num_flavor_options; @@ -2282,6 +2304,43 @@ arm_linux_svr4_fetch_link_map_offsets (void) return lmp; } +/* Test whether the coff symbol specific value corresponds to a Thumb + function. */ + +static int +coff_sym_is_thumb (int val) +{ + return (val == C_THUMBEXT || + val == C_THUMBSTAT || + val == C_THUMBEXTFUNC || + val == C_THUMBSTATFUNC || + val == C_THUMBLABEL); +} + +/* arm_coff_make_msymbol_special() + arm_elf_make_msymbol_special() + + These functions test whether the COFF or ELF symbol corresponds to + an address in thumb code, and set a "special" bit in a minimal + symbol to indicate that it does. */ + +void +arm_elf_make_msymbol_special(asymbol *sym, struct minimal_symbol *msym) +{ + /* Thumb symbols are of type STT_LOPROC, (synonymous with + STT_ARM_TFUNC). */ + if (ELF_ST_TYPE (((elf_symbol_type *)sym)->internal_elf_sym.st_info) + == STT_LOPROC) + MSYMBOL_SET_SPECIAL (msym); +} + +void +arm_coff_make_msymbol_special(int val, struct minimal_symbol *msym) +{ + if (coff_sym_is_thumb (val)) + MSYMBOL_SET_SPECIAL (msym); +} + void _initialize_arm_tdep (void) { @@ -2359,16 +2418,3 @@ The valid values are:\n"); prologue_cache.saved_regs = (CORE_ADDR *) xcalloc (1, SIZEOF_FRAME_SAVED_REGS); } - -/* Test whether the coff symbol specific value corresponds to a Thumb - function. */ - -int -coff_sym_is_thumb (int val) -{ - return (val == C_THUMBEXT || - val == C_THUMBSTAT || - val == C_THUMBEXTFUNC || - val == C_THUMBSTATFUNC || - val == C_THUMBLABEL); -} diff --git a/gdb/config/arm/tm-arm.h b/gdb/config/arm/tm-arm.h index 0ff2c337c06..b203da12074 100644 --- a/gdb/config/arm/tm-arm.h +++ b/gdb/config/arm/tm-arm.h @@ -409,42 +409,16 @@ void arm_software_single_step (int, int); CORE_ADDR arm_get_next_pc (CORE_ADDR pc); -/* Macros for setting and testing a bit in a minimal symbol that marks - it as Thumb function. The MSB of the minimal symbol's "info" field - is used for this purpose. This field is already being used to store - the symbol size, so the assumption is that the symbol size cannot - exceed 2^31. - - COFF_MAKE_MSYMBOL_SPECIAL - ELF_MAKE_MSYMBOL_SPECIAL - - These macros test whether the COFF or ELF symbol corresponds to a - thumb function, and set a "special" bit in a minimal symbol to - indicate that it does. - - MSYMBOL_SET_SPECIAL Actually sets the "special" bit. - MSYMBOL_IS_SPECIAL Tests the "special" bit in a minimal symbol. - MSYMBOL_SIZE Returns the size of the minimal symbol, - i.e. the "info" field with the "special" bit - masked out - */ - -extern int coff_sym_is_thumb (int val); - -#define MSYMBOL_SET_SPECIAL(msym) \ - MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) | 0x80000000) -#define MSYMBOL_IS_SPECIAL(msym) \ - (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0) -#define MSYMBOL_SIZE(msym) \ - ((long) MSYMBOL_INFO (msym) & 0x7fffffff) - -/* Thumb symbols are of type STT_LOPROC, (synonymous with STT_ARM_TFUNC) */ -#define ELF_MAKE_MSYMBOL_SPECIAL(sym,msym) \ - { if(ELF_ST_TYPE(((elf_symbol_type *)(sym))->internal_elf_sym.st_info) == STT_LOPROC) \ - MSYMBOL_SET_SPECIAL(msym); } - -#define COFF_MAKE_MSYMBOL_SPECIAL(val,msym) \ - { if(coff_sym_is_thumb(val)) MSYMBOL_SET_SPECIAL(msym); } + +struct minimal_symbol; + +void arm_elf_make_msymbol_special(asymbol *, struct minimal_symbol *); +#define ELF_MAKE_MSYMBOL_SPECIAL(SYM,MSYM) \ + arm_elf_make_msymbol_special (SYM, MSYM) + +void arm_coff_make_msymbol_special(int, struct minimal_symbol *); +#define COFF_MAKE_MSYMBOL_SPECIAL(VAL,MSYM) \ + arm_coff_make_msymbol_special (VAL, MSYM) /* The first 0x20 bytes are the trap vectors. */ #define LOWEST_PC 0x20 -- 2.30.2