diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-28 15:28:26 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-28 15:28:26 -0400 |
commit | 0c1bcd23274e9f465dc43eda4fc467150631f824 (patch) | |
tree | a7ebad33d064631f80c6b016da5cb3e2df3eedae /gdb/arm-tdep.c | |
parent | f07fad95a949b070e51a18276b8f1e03cf86490f (diff) | |
download | gdb-0c1bcd23274e9f465dc43eda4fc467150631f824.zip gdb-0c1bcd23274e9f465dc43eda4fc467150631f824.tar.gz gdb-0c1bcd23274e9f465dc43eda4fc467150631f824.tar.bz2 |
gdb: convert obj_section macros to methods
Convert these three macros to methods of obj_section. The problem fixed
by the following patch is caused by an out of bound access of the
objfile::section_offsets vector. Since this is deep in macros, we don't
get a clear backtrace and it's difficult to debug. Changing that to
methods means we can step in them and break on them.
Because their implementation requires knowing about struct objfile, move
struct obj_section below struct objfile in objfiles.h.
The obj_section_offset was used in one place as an lvalue to set
offsets, in machoread.c. Replace that with a set_offset method.
Add the objfile::section_offset and objfile::set_section_offset methods
to improve encapsulation (reduce other objects poking into struct
objfile's internals).
gdb/ChangeLog:
* objfiles.h (struct obj_section): Move down.
<offset, set_offset, addr, endaddr>: New.
(obj_section_offset, obj_section_addr, obj_section_endaddr),
replace all users to use obj_section methods.
(struct objfile) <section_offset, set_section_offset>: New.
Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r-- | gdb/arm-tdep.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 339e032..09b38e5 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -395,8 +395,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start) data->section_maps_sorted[section_idx] = true; } - struct arm_mapping_symbol map_key - = { memaddr - obj_section_addr (sec), 0 }; + arm_mapping_symbol map_key = { memaddr - sec->addr (), 0 }; arm_mapping_symbol_vec::const_iterator it = std::lower_bound (map.begin (), map.end (), map_key); @@ -409,7 +408,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start) if (it->value == map_key.value) { if (start) - *start = it->value + obj_section_addr (sec); + *start = it->value + sec->addr (); return it->type; } } @@ -420,7 +419,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start) = it - 1; if (start) - *start = prev_it->value + obj_section_addr (sec); + *start = prev_it->value + sec->addr (); return prev_it->type; } } @@ -2218,7 +2217,7 @@ arm_exidx_new_objfile (struct objfile *objfile) NULL }; - CORE_ADDR pc = pers + obj_section_offset (pers_sec); + CORE_ADDR pc = pers + pers_sec->offset (); int k; for (k = 0; personality[k]; k++) @@ -2303,7 +2302,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start) if (sec != NULL) { struct arm_exidx_data *data; - struct arm_exidx_entry map_key = { memaddr - obj_section_addr (sec), 0 }; + struct arm_exidx_entry map_key = { memaddr - sec->addr (), 0 }; data = arm_exidx_data_key.get (sec->objfile->obfd); if (data != NULL) @@ -2323,7 +2322,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start) if (idx->addr == map_key.addr) { if (start) - *start = idx->addr + obj_section_addr (sec); + *start = idx->addr + sec->addr (); return idx->entry; } } @@ -2332,7 +2331,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start) { idx = idx - 1; if (start) - *start = idx->addr + obj_section_addr (sec); + *start = idx->addr + sec->addr (); return idx->entry; } } |