]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-archer-pie-addons.patch
- update to gdb-7.0-7.fc12.src.rpm; but leave cactus patches as these seem newer
[packages/gdb.git] / gdb-archer-pie-addons.patch
CommitLineData
ab050a48
BZ
1--- a/gdb/dwarf2read.c
2+++ b/gdb/dwarf2read.c
3@@ -5754,7 +5754,12 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
4 {
5 struct attribute *attr;
6 struct symbol *sym;
7- CORE_ADDR base = (CORE_ADDR) 0;
8+ struct objfile *objfile = cu->objfile;
9+ CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
10+ SECT_OFF_TEXT (objfile));
11+ /* This is used only for DW_AT_data_member_location entries. */
12+ CORE_ADDR base = 0;
13+ int base_p = 0;
14
15 attr = dwarf2_attr (die, DW_AT_location, cu);
16 if (attr)
17@@ -5763,6 +5768,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
18 if (attr_form_is_block (attr))
19 {
20 base = decode_locdesc (DW_BLOCK (attr), cu);
21+ base_p = 1;
22 }
23 else if (attr_form_is_section_offset (attr))
24 {
25@@ -5824,12 +5830,15 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
26 else
27 dwarf2_complex_location_expr_complaint ();
28
29- SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
30+ if (!base_p)
31+ dwarf2_invalid_attrib_class_complaint
32+ ("DW_AT_data_member_location", "common block member");
33+ SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset + baseaddr;
34 add_symbol_to_list (sym, &global_symbols);
35 }
36
37 if (SYMBOL_CLASS (sym) == LOC_STATIC)
38- SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym));
39+ SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym) - baseaddr);
40 else
41 SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
42 FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
43@@ -5843,7 +5852,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
44
45 sym = new_symbol (die, type, cu);
46 /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */
47- SYMBOL_VALUE_ADDRESS (sym) = base;
48+ SYMBOL_VALUE_ADDRESS (sym) = base + baseaddr;
49
50 set_die_type (die, type, cu);
51 }
52--- a/gdb/exec.c
53+++ b/gdb/exec.c
54@@ -32,6 +32,7 @@
55 #include "exec.h"
56 #include "observer.h"
57 #include "arch-utils.h"
58+#include "solib.h"
59
60 #include <fcntl.h>
61 #include "readline/readline.h"
62@@ -220,6 +221,10 @@ exec_file_attach (char *filename, int from_tty)
63 char *scratch_pathname;
64 int scratch_chan;
65 struct target_section *sections = NULL, *sections_end = NULL;
66+ struct target_section *p;
67+ int addr_bit;
68+ CORE_ADDR mask = CORE_ADDR_MAX;
69+ CORE_ADDR displacement;
70
71 scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
72 write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
73@@ -288,12 +293,23 @@ exec_file_attach (char *filename, int from_tty)
74 scratch_pathname, bfd_errmsg (bfd_get_error ()));
75 }
76
77+ set_gdbarch_from_file (exec_bfd);
78+
79+ addr_bit = gdbarch_addr_bit (target_gdbarch);
80+ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
81+ mask = ((CORE_ADDR) 1 << addr_bit) - 1;
82+
83+ displacement = solib_exec_displacement ();
84+ for (p = sections; p < sections_end; p++)
85+ {
86+ p->addr = (p->addr + displacement) & mask;
87+ p->endaddr = (p->endaddr + displacement) & mask;
88+ }
89+
90 exec_bfd_mtime = bfd_get_mtime (exec_bfd);
91
92 validate_files ();
93
94- set_gdbarch_from_file (exec_bfd);
95-
96 /* Add the executable's sections to the current address spaces'
97 list of sections. */
98 add_target_sections (sections, sections_end);
99--- a/gdb/gdbtypes.h
100+++ b/gdb/gdbtypes.h
101@@ -966,6 +966,7 @@ extern void allocate_cplus_struct_type (struct type *);
102 #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
103 #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
104 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
105+/* This address is unrelocated by the objfile's ANOFFSET. */
106 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
107 #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
108 #define SET_FIELD_BITPOS(thisfld, bitpos) \
109@@ -974,6 +975,7 @@ extern void allocate_cplus_struct_type (struct type *);
110 #define SET_FIELD_PHYSNAME(thisfld, name) \
111 (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \
112 FIELD_STATIC_PHYSNAME (thisfld) = (name))
113+/* This address is unrelocated by the objfile's ANOFFSET. */
114 #define SET_FIELD_PHYSADDR(thisfld, addr) \
115 (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \
116 FIELD_STATIC_PHYSADDR (thisfld) = (addr))
117@@ -989,6 +991,7 @@ extern void allocate_cplus_struct_type (struct type *);
118 #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
119 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
120 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
121+/* This address is unrelocated by the objfile's ANOFFSET. */
122 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
123 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
124 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
125--- a/gdb/jv-lang.c
126+++ b/gdb/jv-lang.c
127@@ -416,7 +416,8 @@ java_link_class_type (struct gdbarch *gdbarch,
128
129 fields = NULL;
130 nfields--; /* First set up dummy "class" field. */
131- SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas));
132+ SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas)
133+ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
134 TYPE_FIELD_NAME (type, nfields) = "class";
135 TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
136 SET_TYPE_FIELD_PRIVATE (type, nfields);
137@@ -462,7 +463,8 @@ java_link_class_type (struct gdbarch *gdbarch,
138 SET_TYPE_FIELD_PROTECTED (type, i);
139 }
140 if (accflags & 0x0008) /* ACC_STATIC */
141- SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset);
142+ SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset
143+ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
144 else
145 TYPE_FIELD_BITPOS (type, i) = 8 * boffset;
146 if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */
147--- a/gdb/solib-svr4.c
148+++ b/gdb/solib-svr4.c
149@@ -1621,7 +1621,10 @@ svr4_exec_displacement (void)
150 if (target_auxv_search (&current_target, AT_ENTRY, &entry_point) == 1)
151 return entry_point - exec_entry_point (exec_bfd, &current_target);
152
153- return svr4_static_exec_displacement ();
154+ if (!ptid_equal (inferior_ptid, null_ptid))
155+ return svr4_static_exec_displacement ();
156+
157+ return 0;
158 }
159
160 /* Relocate the main executable. This function should be called upon
161@@ -1632,7 +1635,7 @@ svr4_exec_displacement (void)
162 static void
163 svr4_relocate_main_executable (void)
164 {
165- CORE_ADDR displacement = svr4_exec_displacement ();
166+ CORE_ADDR displacement = solib_exec_displacement ();
167
168 /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new
169 difference of in-memory vs. in-file addresses and we could already
170@@ -1975,6 +1978,7 @@ _initialize_svr4_solib (void)
171 svr4_so_ops.free_so = svr4_free_so;
172 svr4_so_ops.clear_solib = svr4_clear_solib;
173 svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
174+ svr4_so_ops.exec_displacement = svr4_exec_displacement;
175 svr4_so_ops.special_symbol_handling = svr4_special_symbol_handling;
176 svr4_so_ops.current_sos = svr4_current_sos;
177 svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
178--- a/gdb/solib.c
179+++ b/gdb/solib.c
180@@ -1014,6 +1014,19 @@ solib_create_inferior_hook (int from_tty)
181 ops->solib_create_inferior_hook (from_tty);
182 }
183
184+/* Query the difference of in-memory VMA addresses vs. exec_bfd VMAs. */
185+
186+CORE_ADDR
187+solib_exec_displacement (void)
188+{
189+ struct target_so_ops *ops = solib_ops (target_gdbarch);
190+
191+ if (ops->exec_displacement != NULL)
192+ return (*ops->exec_displacement) ();
193+ else
194+ return 0;
195+}
196+
197 /* GLOBAL FUNCTION
198
199 in_solib_dynsym_resolve_code -- check to see if an address is in
200--- a/gdb/solib.h
201+++ b/gdb/solib.h
202@@ -43,6 +43,8 @@ extern int solib_read_symbols (struct so_list *, int);
203
204 extern void solib_create_inferior_hook (int from_tty);
205
206+extern CORE_ADDR solib_exec_displacement (void);
207+
208 /* If ADDR lies in a shared library, return its name. */
209
210 extern char *solib_name_from_address (CORE_ADDR);
211--- a/gdb/solist.h
212+++ b/gdb/solist.h
213@@ -89,6 +89,9 @@ struct target_so_ops
214 /* Target dependent code to run after child process fork. */
215 void (*solib_create_inferior_hook) (int from_tty);
216
217+ /* Query the difference of in-memory VMA addresses vs. exec_bfd VMAs. */
218+ CORE_ADDR (*exec_displacement) (void);
219+
220 /* Do additional symbol handling, lookup, etc. after symbols
221 for a shared object have been loaded. */
222 void (*special_symbol_handling) (void);
223--- a/gdb/symfile.c
224+++ b/gdb/symfile.c
225@@ -873,15 +873,36 @@ syms_from_objfile (struct objfile *objfile,
226 if an error occurs during symbol reading. */
227 old_chain = make_cleanup_free_objfile (objfile);
228
229- /* If ADDRS and OFFSETS are both NULL, put together a dummy address
230- list. We now establish the convention that an addr of zero means
231- no load address was specified. */
232+ /* If ADDRS and OFFSETS are both NULL, put together a dummy offset list. */
233+
234 if (! addrs && ! offsets)
235 {
236- local_addr
237- = alloc_section_addr_info (bfd_count_sections (objfile->obfd));
238- make_cleanup (xfree, local_addr);
239- addrs = local_addr;
240+ /* Relocateble files have an exception in default_symfile_offsets which
241+ applies only for ADDRS. But calling solib_exec_displacement is more
242+ suitable for OFFSETS. Fortunately we never need the both
243+ functionalities simultaneously and in other cases zeroed ADDRS and
244+ zeroed OFFSETS are equivalent. */
245+
246+ if ((bfd_get_file_flags (objfile->obfd) & (EXEC_P | DYNAMIC)) == 0)
247+ {
248+ local_addr
249+ = alloc_section_addr_info (bfd_count_sections (objfile->obfd));
250+ make_cleanup (xfree, local_addr);
251+ addrs = local_addr;
252+ }
253+ else
254+ {
255+ CORE_ADDR displacement = 0;
256+ int i;
257+
258+ if (mainline)
259+ displacement = solib_exec_displacement ();
260+
261+ num_offsets = bfd_count_sections (objfile->obfd);
262+ offsets = alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets));
263+ for (i = 0; i < num_offsets; i++)
264+ offsets->offsets[i] = displacement;
265+ }
266 }
267
268 /* Now either addrs or offsets is non-zero. */
269--- a/gdb/value.c
270+++ b/gdb/value.c
271@@ -1890,7 +1890,8 @@ value_static_field (struct type *type, int fieldno)
272 if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
273 {
274 retval = value_at (TYPE_FIELD_TYPE (type, fieldno),
275- TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
276+ TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)
277+ + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
278 }
279 else
280 {
281@@ -1920,7 +1921,8 @@ value_static_field (struct type *type, int fieldno)
282 }
283 if (retval && VALUE_LVAL (retval) == lval_memory)
284 SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
285- value_address (retval));
286+ value_address (retval)
287+ - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
288 }
289 return retval;
290 }
This page took 1.452485 seconds and 4 git commands to generate.