]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.3-pie-20050110.patch
- update to 6.8.91.20090930-1 from fedora
[packages/gdb.git] / gdb-6.3-pie-20050110.patch
CommitLineData
3a58abaf
AM
12007-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
2
3 Port to GDB-6.7.1.
4
52007-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
6
7 Port to post-GDB-6.7.1 multi-PC breakpoints.
8
92007-11-09 Jan Kratochvil <jan.kratochvil@redhat.com>
10
11 * solib-svr4.c (svr4_current_sos): Fix segfault on NULL EXEC_BFD.
12
132008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
14
15 Port to GDB-6.8pre.
16
172008-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
18
19 Port to gdb-6.7.50.20080227.
20
212008-06-01 Jan Kratochvil <jan.kratochvil@redhat.com>
22
23 Fix crash on a watchpoint update on an inferior stop.
24
252008-09-01 Jan Kratochvil <jan.kratochvil@redhat.com>
26
27 Fix scan_dyntag() for binaries provided by valgrind (BZ 460319).
28
7566401a 29Index: gdb-6.8.91.20090925/gdb/amd64-tdep.c
3a58abaf 30===================================================================
7566401a
ER
31--- gdb-6.8.91.20090925.orig/gdb/amd64-tdep.c 2009-09-25 10:25:39.000000000 +0200
32+++ gdb-6.8.91.20090925/gdb/amd64-tdep.c 2009-09-25 10:25:45.000000000 +0200
3a58abaf
AM
33@@ -36,6 +36,7 @@
34 #include "regcache.h"
35 #include "regset.h"
36 #include "symfile.h"
37+#include "exceptions.h"
38
39 #include "gdb_assert.h"
40
7566401a 41@@ -1591,18 +1592,31 @@ amd64_analyze_stack_align (CORE_ADDR pc,
3a58abaf
AM
42 Any function that doesn't start with this sequence will be assumed
43 to have no prologue and thus no valid frame pointer in %rbp. */
44
45-static CORE_ADDR
7566401a
ER
46-amd64_analyze_prologue (struct gdbarch *gdbarch,
47- CORE_ADDR pc, CORE_ADDR current_pc,
3a58abaf
AM
48- struct amd64_frame_cache *cache)
49+struct amd64_analyze_prologue_data
50+ {
7566401a 51+ struct gdbarch *gdbarch;
3a58abaf
AM
52+ CORE_ADDR pc, current_pc;
53+ struct amd64_frame_cache *cache;
54+ CORE_ADDR retval;
55+ };
56+
57+static int
58+amd64_analyze_prologue_1 (void *data_pointer)
59 {
60+ struct amd64_analyze_prologue_data *data = data_pointer;
7566401a 61+ struct gdbarch *gdbarch = data->gdbarch;
3a58abaf
AM
62+ CORE_ADDR pc = data->pc, current_pc = data->current_pc;
63+ struct amd64_frame_cache *cache = data->cache;
7566401a 64 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
3a58abaf
AM
65 static gdb_byte proto[3] = { 0x48, 0x89, 0xe5 }; /* movq %rsp, %rbp */
66 gdb_byte buf[3];
67 gdb_byte op;
68
69 if (current_pc <= pc)
70- return current_pc;
71+ {
72+ data->retval = current_pc;
73+ return 1;
74+ }
75
76 pc = amd64_analyze_stack_align (pc, current_pc, cache);
77
7566401a 78@@ -1617,18 +1631,59 @@ amd64_analyze_prologue (struct gdbarch *
3a58abaf
AM
79
80 /* If that's all, return now. */
81 if (current_pc <= pc + 1)
82- return current_pc;
83+ {
84+ data->retval = current_pc;
85+ return 1;
86+ }
87
88 /* Check for `movq %rsp, %rbp'. */
89 read_memory (pc + 1, buf, 3);
90 if (memcmp (buf, proto, 3) != 0)
91- return pc + 1;
92+ {
93+ data->retval = pc + 1;
94+ return 1;
95+ }
96
97 /* OK, we actually have a frame. */
98 cache->frameless_p = 0;
99- return pc + 4;
100+ data->retval = pc + 4;
101+ return 1;
102 }
103
104+ data->retval = pc;
105+ return 1;
106+}
107+
108+/* Catch memory read errors and return just PC in such case.
109+ It occurs very early on enable_break->new_symfile_objfile->
110+ ->breakpoint_re_set->decode_line_1->decode_variable_1->
111+ ->find_function_start_sal */
112+
113+static CORE_ADDR
7566401a
ER
114+amd64_analyze_prologue (struct gdbarch *gdbarch,
115+ CORE_ADDR pc, CORE_ADDR current_pc,
3a58abaf
AM
116+ struct amd64_frame_cache *cache)
117+{
118+ int status;
119+ struct amd64_analyze_prologue_data data;
120+ struct ui_file *saved_gdb_stderr;
121+
122+ /* Suppress error messages. */
123+ saved_gdb_stderr = gdb_stderr;
124+ gdb_stderr = ui_file_new ();
125+
7566401a 126+ data.gdbarch = gdbarch;
3a58abaf
AM
127+ data.pc = pc;
128+ data.current_pc = current_pc;
129+ data.cache = cache;
130+ status = catch_errors (amd64_analyze_prologue_1, &data, "", RETURN_MASK_ALL);
131+
132+ /* Stop suppressing error messages. */
133+ ui_file_delete (gdb_stderr);
134+ gdb_stderr = saved_gdb_stderr;
135+
136+ if (status)
137+ return data.retval;
138 return pc;
139 }
140
7566401a 141Index: gdb-6.8.91.20090925/gdb/auxv.c
3a58abaf 142===================================================================
7566401a
ER
143--- gdb-6.8.91.20090925.orig/gdb/auxv.c 2009-07-02 19:25:52.000000000 +0200
144+++ gdb-6.8.91.20090925/gdb/auxv.c 2009-09-25 10:25:45.000000000 +0200
145@@ -78,7 +78,7 @@ procfs_xfer_auxv (struct target_ops *ops
3a58abaf
AM
146 Return 1 if an entry was read into *TYPEP and *VALP. */
147 static int
148 default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
149- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
150+ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp)
151 {
152 const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
153 / TARGET_CHAR_BIT;
7566401a 154@@ -106,7 +106,7 @@ default_auxv_parse (struct target_ops *o
3a58abaf
AM
155 Return 1 if an entry was read into *TYPEP and *VALP. */
156 int
157 target_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
158- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
159+ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp)
160 {
161 struct target_ops *t;
162 for (t = ops; t != NULL; t = t->beneath)
7566401a 163@@ -121,9 +121,10 @@ target_auxv_parse (struct target_ops *op
3a58abaf
AM
164 an error getting the information. On success, return 1 after
165 storing the entry's value field in *VALP. */
166 int
167-target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
168+target_auxv_search (struct target_ops *ops, ULONGEST match, CORE_ADDR *valp)
169 {
170- CORE_ADDR type, val;
171+ CORE_ADDR val;
172+ ULONGEST at_type;
173 gdb_byte *data;
174 LONGEST n = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL, &data);
175 gdb_byte *ptr = data;
7566401a 176@@ -133,10 +134,10 @@ target_auxv_search (struct target_ops *o
3a58abaf
AM
177 return n;
178
179 while (1)
180- switch (target_auxv_parse (ops, &ptr, data + n, &type, &val))
181+ switch (target_auxv_parse (ops, &ptr, data + n, &at_type, &val))
182 {
183 case 1: /* Here's an entry, check it. */
184- if (type == match)
185+ if (at_type == match)
186 {
187 xfree (data);
188 *valp = val;
7566401a 189@@ -159,7 +160,8 @@ target_auxv_search (struct target_ops *o
3a58abaf
AM
190 int
191 fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
192 {
193- CORE_ADDR type, val;
194+ CORE_ADDR val;
195+ ULONGEST at_type;
196 gdb_byte *data;
197 LONGEST len = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL,
198 &data);
7566401a 199@@ -169,13 +171,13 @@ fprint_target_auxv (struct ui_file *file
3a58abaf
AM
200 if (len <= 0)
201 return len;
202
203- while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
204+ while (target_auxv_parse (ops, &ptr, data + len, &at_type, &val) > 0)
205 {
206 const char *name = "???";
207 const char *description = "";
208 enum { dec, hex, str } flavor = hex;
209
210- switch (type)
211+ switch (at_type)
212 {
213 #define TAG(tag, text, kind) \
214 case tag: name = #tag; description = text; flavor = kind; break
7566401a 215@@ -231,7 +233,7 @@ fprint_target_auxv (struct ui_file *file
3a58abaf
AM
216 }
217
218 fprintf_filtered (file, "%-4s %-20s %-30s ",
219- plongest (type), name, description);
220+ plongest (at_type), name, description);
221 switch (flavor)
222 {
223 case dec:
7566401a 224@@ -253,7 +255,7 @@ fprint_target_auxv (struct ui_file *file
3a58abaf
AM
225 break;
226 }
227 ++ents;
228- if (type == AT_NULL)
229+ if (at_type == AT_NULL)
230 break;
231 }
232
7566401a 233Index: gdb-6.8.91.20090925/gdb/auxv.h
3a58abaf 234===================================================================
7566401a
ER
235--- gdb-6.8.91.20090925.orig/gdb/auxv.h 2009-06-07 21:07:08.000000000 +0200
236+++ gdb-6.8.91.20090925/gdb/auxv.h 2009-09-25 10:25:45.000000000 +0200
237@@ -31,14 +31,14 @@
3a58abaf
AM
238 Return 1 if an entry was read into *TYPEP and *VALP. */
239 extern int target_auxv_parse (struct target_ops *ops,
240 gdb_byte **readptr, gdb_byte *endptr,
241- CORE_ADDR *typep, CORE_ADDR *valp);
242+ ULONGEST *typep, CORE_ADDR *valp);
243
244 /* Extract the auxiliary vector entry with a_type matching MATCH.
245 Return zero if no such entry was found, or -1 if there was
246 an error getting the information. On success, return 1 after
247 storing the entry's value field in *VALP. */
248 extern int target_auxv_search (struct target_ops *ops,
249- CORE_ADDR match, CORE_ADDR *valp);
250+ ULONGEST match, CORE_ADDR *valp);
251
252 /* Print the contents of the target's AUXV on the specified file. */
253 extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops);
7566401a 254Index: gdb-6.8.91.20090925/gdb/dwarf2read.c
3a58abaf 255===================================================================
7566401a
ER
256--- gdb-6.8.91.20090925.orig/gdb/dwarf2read.c 2009-09-25 10:25:39.000000000 +0200
257+++ gdb-6.8.91.20090925/gdb/dwarf2read.c 2009-09-25 10:25:45.000000000 +0200
258@@ -1717,7 +1717,7 @@ dwarf2_build_psymtabs (struct objfile *o
259 dwarf2_read_section (objfile, &dwarf2_per_objfile->eh_frame);
260 dwarf2_read_section (objfile, &dwarf2_per_objfile->frame);
3a58abaf
AM
261
262- if (mainline
263+ if ((mainline == 1)
264 || (objfile->global_psymbols.size == 0
265 && objfile->static_psymbols.size == 0))
266 {
7566401a 267Index: gdb-6.8.91.20090925/gdb/elfread.c
3a58abaf 268===================================================================
7566401a
ER
269--- gdb-6.8.91.20090925.orig/gdb/elfread.c 2009-09-25 10:25:38.000000000 +0200
270+++ gdb-6.8.91.20090925/gdb/elfread.c 2009-09-25 10:25:45.000000000 +0200
271@@ -681,7 +681,7 @@ elf_symfile_read (struct objfile *objfil
3a58abaf
AM
272 /* If we are reinitializing, or if we have never loaded syms yet,
273 set table to empty. MAINLINE is cleared so that *_read_psymtab
274 functions do not all also re-initialize the psymbol table. */
275- if (mainline)
276+ if (mainline == 1)
277 {
278 init_psymbol_list (objfile, 0);
279 mainline = 0;
7566401a 280Index: gdb-6.8.91.20090925/gdb/infrun.c
3a58abaf 281===================================================================
7566401a
ER
282--- gdb-6.8.91.20090925.orig/gdb/infrun.c 2009-09-25 10:25:39.000000000 +0200
283+++ gdb-6.8.91.20090925/gdb/infrun.c 2009-09-25 10:25:45.000000000 +0200
284@@ -3659,6 +3659,10 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
3a58abaf
AM
285 #endif
286 target_terminal_inferior ();
287
288+ /* For PIE executables, we dont really know where the
7566401a
ER
289+ breakpoints are going to be until we start up the inferior. */
290+ enable_breakpoints_after_startup ();
3a58abaf
AM
291+
292 /* If requested, stop when the dynamic linker notifies
293 gdb of events. This allows the user to get control
294 and place breakpoints in initializer routines for
7566401a 295Index: gdb-6.8.91.20090925/gdb/objfiles.c
3a58abaf 296===================================================================
7566401a
ER
297--- gdb-6.8.91.20090925.orig/gdb/objfiles.c 2009-09-25 10:25:38.000000000 +0200
298+++ gdb-6.8.91.20090925/gdb/objfiles.c 2009-09-25 10:25:45.000000000 +0200
299@@ -53,6 +53,9 @@
300 #include "observer.h"
301 #include "complaints.h"
3a58abaf
AM
302
303+#include "auxv.h"
304+#include "elf/common.h"
305+
306 /* Prototypes for local functions */
307
308 static void objfile_alloc_data (struct objfile *objfile);
7566401a 309@@ -280,9 +283,17 @@ init_entry_point_info (struct objfile *o
3a58abaf
AM
310 CORE_ADDR
311 entry_point_address (void)
312 {
3a58abaf 313+ int ret;
3a58abaf 314+
7566401a
ER
315 struct gdbarch *gdbarch;
316 CORE_ADDR entry_point;
317
3a58abaf
AM
318+ /* Find the address of the entry point of the program from the
319+ auxv vector. */
7566401a 320+ ret = target_auxv_search (&current_target, AT_ENTRY, &entry_point);
3a58abaf 321+ if (ret == 1)
7566401a 322+ return entry_point;
3a58abaf 323+
7566401a
ER
324 if (symfile_objfile == NULL)
325 return 0;
326
327Index: gdb-6.8.91.20090925/gdb/solib-svr4.c
3a58abaf 328===================================================================
7566401a
ER
329--- gdb-6.8.91.20090925.orig/gdb/solib-svr4.c 2009-09-25 10:25:39.000000000 +0200
330+++ gdb-6.8.91.20090925/gdb/solib-svr4.c 2009-09-25 10:28:07.000000000 +0200
331@@ -47,6 +47,7 @@
3a58abaf
AM
332 #include "exec.h"
333 #include "auxv.h"
334 #include "exceptions.h"
335+#include "command.h"
336
337 static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
338 static int svr4_have_link_map_offsets (void);
7566401a 339@@ -359,7 +360,9 @@ solib_svr4_inferior_exit (int pid)
3a58abaf
AM
340
341 /* Local function prototypes */
342
343+#if 0
344 static int match_main (char *);
345+#endif
346
347 static CORE_ADDR bfd_lookup_symbol (bfd *, char *);
348
7566401a 349@@ -600,10 +603,12 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
3a58abaf
AM
350 int arch_size, step, sect_size;
351 long dyn_tag;
352 CORE_ADDR dyn_ptr, dyn_addr;
353+ CORE_ADDR reloc_addr = 0;
354 gdb_byte *bufend, *bufstart, *buf;
355 Elf32_External_Dyn *x_dynp_32;
356 Elf64_External_Dyn *x_dynp_64;
357 struct bfd_section *sect;
358+ int ret;
359
360 if (abfd == NULL)
361 return 0;
7566401a 362@@ -615,19 +620,81 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
3a58abaf 363 if (arch_size == -1)
7566401a 364 return 0;
3a58abaf
AM
365
366+ /* The auxv vector based relocatable files reading is limited to the main
367+ executable. */
368+ gdb_assert (abfd == exec_bfd || ptr == NULL);
369+
370+ if (ptr != NULL)
371+ {
372+ CORE_ADDR entry_addr;
373+
374+ /* Find the address of the entry point of the program from the
375+ auxv vector. */
376+ ret = target_auxv_search (&current_target, AT_ENTRY, &entry_addr);
377+
378+ if (ret == 0 || ret == -1)
379+ {
380+ /* No auxv info, maybe an older kernel. Fake our way through. */
381+ entry_addr = bfd_get_start_address (exec_bfd);
382+
383+ if (debug_solib)
384+ fprintf_unfiltered (gdb_stdlog,
7566401a
ER
385+ "elf_locate_base: program entry address not found. Using bfd's %s for %s\n",
386+ paddress (target_gdbarch, entry_addr), exec_bfd->filename);
3a58abaf
AM
387+ }
388+ else
389+ {
390+ if (debug_solib)
391+ fprintf_unfiltered (gdb_stdlog,
7566401a
ER
392+ "elf_locate_base: found program entry address %s for %s\n",
393+ paddress (target_gdbarch, entry_addr), exec_bfd->filename);
3a58abaf
AM
394+ }
395+ reloc_addr = entry_addr - bfd_get_start_address (exec_bfd);
396+ if (debug_solib)
397+ fprintf_unfiltered (gdb_stdlog,
7566401a
ER
398+ "elf_locate_base: expected relocation offset %s for %s\n",
399+ paddress (target_gdbarch, reloc_addr), exec_bfd->filename);
3a58abaf
AM
400+ }
401+
402 /* Find the start address of the .dynamic section. */
403 sect = bfd_get_section_by_name (abfd, ".dynamic");
404 if (sect == NULL)
405- return 0;
406+ {
407+ if (debug_solib)
408+ fprintf_unfiltered (gdb_stdlog,
409+ "elf_locate_base: .dynamic section not found in %s -- return now\n",
410+ exec_bfd->filename);
411+ return 0;
412+ }
413+ else
414+ {
415+ if (debug_solib)
416+ fprintf_unfiltered (gdb_stdlog,
417+ "elf_locate_base: .dynamic section found in %s\n",
418+ exec_bfd->filename);
419+ }
420+
421 dyn_addr = bfd_section_vma (abfd, sect);
422+ if (debug_solib)
423+ fprintf_unfiltered (gdb_stdlog,
7566401a
ER
424+ "elf_locate_base: .dynamic addr %s\n",
425+ paddress (target_gdbarch, dyn_addr));
3a58abaf
AM
426
427 /* Read in .dynamic from the BFD. We will get the actual value
428 from memory later. */
429 sect_size = bfd_section_size (abfd, sect);
430 buf = bufstart = alloca (sect_size);
431+ if (debug_solib)
432+ fprintf_unfiltered (gdb_stdlog,
433+ "elf_locate_base: read in .dynamic section\n");
434 if (!bfd_get_section_contents (abfd, sect,
435 buf, 0, sect_size))
436- return 0;
437+ {
438+ if (debug_solib)
439+ fprintf_unfiltered (gdb_stdlog,
440+ "elf_locate_base: couldn't read .dynamic section -- return now\n");
441+ return 0;
442+ }
443
444 /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */
445 step = (arch_size == 32) ? sizeof (Elf32_External_Dyn)
7566401a 446@@ -648,26 +715,105 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
3a58abaf
AM
447 dyn_tag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag);
448 dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr);
449 }
450- if (dyn_tag == DT_NULL)
451+
452+ /* Verify RELOC_ADDR makes sense - it does not have to for valgrind which
453+ supplies us a specially crafted executable in /proc/PID/fd/X while
454+ /proc/PID/auxv corresponds to a different executable (.../memcheck). */
455+ if (reloc_addr)
456+ {
457+ gdb_byte tag_buf[8];
458+ CORE_ADDR tag_addr;
459+
460+ tag_addr = dyn_addr + (buf - bufstart) + reloc_addr;
461+ if (target_read_memory (tag_addr, tag_buf, arch_size / 8) == 0)
462+ {
463+ if (memcmp (tag_buf, buf, arch_size / 8) != 0)
464+ {
465+ if (debug_solib)
466+ fprintf_unfiltered (gdb_stdlog,
467+ "elf_locate_base: tag at offset 0x%lx does not match,"
468+ " dropping relocation offset %s\n",
7566401a 469+ (unsigned long) (buf - bufstart), paddress (target_gdbarch, reloc_addr));
3a58abaf
AM
470+ reloc_addr = 0;
471+ }
472+ }
473+ else
474+ {
475+ if (debug_solib)
476+ fprintf_unfiltered (gdb_stdlog,
477+ "elf_locate_base: tag at offset 0x%lx is not readable,"
478+ " dropping relocation offset %s\n",
7566401a 479+ (unsigned long) (buf - bufstart), paddress (target_gdbarch, reloc_addr));
3a58abaf
AM
480+ reloc_addr = 0;
481+ }
482+ }
483+
484+ if (dyn_tag == DT_NULL)
485 return 0;
486- if (dyn_tag == dyntag)
487- {
488- /* If requested, try to read the runtime value of this .dynamic
489- entry. */
490- if (ptr)
491- {
492- struct type *ptr_type;
493- gdb_byte ptr_buf[8];
494- CORE_ADDR ptr_addr;
495-
496- ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
497- ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
498- if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
499- dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
500- *ptr = dyn_ptr;
501- }
502- return 1;
503- }
504+ if (dyn_tag == dyntag)
505+ {
506+ /* If requested, try to read the runtime value of this .dynamic
507+ entry. */
508+ if (ptr)
509+ {
510+ gdb_byte ptr_buf[8];
511+ CORE_ADDR ptr_addr;
512+ int got;
513+
514+ ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
515+ if (ptr != NULL)
516+ {
517+ if (debug_solib)
518+ fprintf_unfiltered (gdb_stdlog,
7566401a
ER
519+ "elf_locate_base: unrelocated ptr addr %s\n",
520+ paddress (target_gdbarch, ptr_addr));
3a58abaf
AM
521+ ptr_addr += reloc_addr;
522+ if (debug_solib)
523+ fprintf_unfiltered (gdb_stdlog,
7566401a 524+ "elf_locate_base: relocated ptr addr %s"
3a58abaf 525+ " (relocation offset %s) for %s\n",
7566401a 526+ paddress (target_gdbarch, ptr_addr), paddress (target_gdbarch, reloc_addr),
3a58abaf
AM
527+ exec_bfd->filename);
528+ }
529+ got = target_read_memory (ptr_addr, ptr_buf, arch_size / 8);
530+ if (got != 0 && reloc_addr)
531+ {
532+ ptr_addr -= reloc_addr;
533+ if (debug_solib)
534+ fprintf_unfiltered (gdb_stdlog,
7566401a 535+ "elf_locate_base: unrelocated back to ptr addr %s"
3a58abaf 536+ " as the memory was unreable for %s\n",
7566401a 537+ paddress (target_gdbarch, ptr_addr), exec_bfd->filename);
3a58abaf
AM
538+ got = target_read_memory (ptr_addr, ptr_buf, arch_size / 8);
539+ }
540+
541+ if (got == 0)
542+ {
543+ struct type *ptr_type;
544+
545+ ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
546+ dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
547+ if (ptr != NULL)
548+ {
549+ if (debug_solib)
550+ fprintf_unfiltered (gdb_stdlog,
7566401a
ER
551+ "elf_locate_base: Tag entry has value %s -- return now\n",
552+ paddress (target_gdbarch, dyn_ptr));
3a58abaf
AM
553+ }
554+ }
555+ else
556+ {
557+ if (ptr != NULL)
558+ {
559+ if (debug_solib)
560+ fprintf_unfiltered (gdb_stdlog,
561+ "elf_locate_base: Couldn't read tag entry value -- return now\n");
562+ }
563+ }
564+ *ptr = dyn_ptr;
565+ }
566+ return 1;
567+ }
568 }
569
570 return 0;
7566401a 571@@ -1040,6 +1186,11 @@ svr4_current_sos (void)
3a58abaf 572 CORE_ADDR ldsomap = 0;
7566401a
ER
573 struct inferior *inf;
574 struct svr4_info *info;
3a58abaf
AM
575+ const char *filename = exec_bfd ? exec_bfd->filename : "<none>";
576+
577+ if (debug_solib)
578+ fprintf_unfiltered (gdb_stdlog,
579+ "svr4_current_sos: exec_bfd %s\n", filename);
580
7566401a
ER
581 if (ptid_equal (inferior_ptid, null_ptid))
582 return NULL;
583@@ -1054,7 +1205,13 @@ svr4_current_sos (void)
3a58abaf
AM
584 /* If we can't find the dynamic linker's base structure, this
585 must not be a dynamically linked executable. Hmm. */
7566401a 586 if (! info->debug_base)
3a58abaf
AM
587- return svr4_default_sos ();
588+ {
589+ if (debug_solib)
590+ fprintf_unfiltered (gdb_stdlog,
591+ "svr4_current_sos: no DT_DEBUG found in %s -- return now\n",
592+ filename);
593+ return svr4_default_sos ();
594+ }
595
596 /* Walk the inferior's link map list, and build our list of
597 `struct so_list' nodes. */
7566401a 598@@ -1074,26 +1231,104 @@ svr4_current_sos (void)
3a58abaf
AM
599 new->lm_info->lm = xzalloc (lmo->link_map_size);
600 make_cleanup (xfree, new->lm_info->lm);
601
602+ if (debug_solib)
603+ fprintf_unfiltered (gdb_stdlog,
7566401a 604+ "svr4_current_sos: read lm at %s\n", paddress (target_gdbarch, lm));
3a58abaf
AM
605 read_memory (lm, new->lm_info->lm, lmo->link_map_size);
606
607 lm = LM_NEXT (new);
608
609+ if (debug_solib)
610+ fprintf_unfiltered (gdb_stdlog,
611+ "svr4_current_sos: is first link entry? %d\n",
612+ IGNORE_FIRST_LINK_MAP_ENTRY (new));
613+
614 /* For SVR4 versions, the first entry in the link map is for the
615 inferior executable, so we must ignore it. For some versions of
616 SVR4, it has no name. For others (Solaris 2.3 for example), it
617 does have a name, so we can no longer use a missing name to
618 decide when to ignore it. */
619- if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
620+ if (exec_bfd != NULL && IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
621 {
7566401a 622- info->main_lm_addr = new->lm_info->lm_addr;
3a58abaf
AM
623- free_so (new);
624- }
625+ /* It is the first link map entry, i.e. it is the main executable. */
626+
627+ if (bfd_get_start_address (exec_bfd) == entry_point_address ())
628+ {
629+ /* Non-pie case, main executable has not been relocated. */
7566401a 630+ info->main_lm_addr = new->lm_info->lm_addr;
3a58abaf
AM
631+ free_so (new);
632+ }
633+ else
634+ {
635+ /* Pie case, main executable has been relocated. */
636+ struct so_list *gdb_solib;
637+
638+ if (debug_solib)
639+ fprintf_unfiltered (gdb_stdlog,
640+ "svr4_current_sos: Processing first link map entry\n");
641+ strncpy (new->so_name, exec_bfd->filename,
642+ SO_NAME_MAX_PATH_SIZE - 1);
643+ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
644+ strcpy (new->so_original_name, new->so_name);
645+ /*new->main = 1;*/
646+ new->main_relocated = 0;
647+
648+ if (debug_solib)
649+ {
650+ fprintf_unfiltered (gdb_stdlog,
651+ "svr4_current_sos: Processing nameless DSO\n");
652+ fprintf_unfiltered (gdb_stdlog,
653+ "svr4_current_sos: adding name %s\n",
654+ new->so_name);
655+ }
656+
657+ for (gdb_solib = master_so_list ();
658+ gdb_solib;
659+ gdb_solib = gdb_solib->next)
660+ {
661+ if (debug_solib)
662+ fprintf_unfiltered (gdb_stdlog,
663+ "svr4_current_sos: compare gdb %s and new %s\n",
664+ gdb_solib->so_name, new->so_name);
665+ if (strcmp (gdb_solib->so_name, new->so_name) == 0)
666+ if (gdb_solib->main_relocated)
667+ {
668+ if (debug_solib)
669+ fprintf_unfiltered (gdb_stdlog,
670+ "svr4_current_sos: found main relocated\n");
671+ break;
672+ }
673+ }
674+
675+ if ((gdb_solib && !gdb_solib->main_relocated) || (!gdb_solib))
676+ {
677+ add_to_target_sections (0 /*from_tty*/, &current_target, new);
678+ new->main = 1;
679+ }
680+
681+ /* We need this in the list of shared libs we return because
682+ solib_add_stub will loop through it and add the symbol file. */
683+ new->next = 0;
684+ *link_ptr = new;
685+ link_ptr = &new->next;
686+ }
687+ } /* End of IGNORE_FIRST_LINK_MAP_ENTRY */
688 else
689 {
690+ /* This is not the first link map entry, i.e. is not the main
691+ executable. Note however that it could be the DSO supplied on
692+ certain systems (i.e. Linux 2.6) containing information about
693+ the vsyscall page. We must ignore such entry. This entry is
694+ nameless (just like the one for the main executable, sigh). */
695+
696 int errcode;
697 char *buffer;
698
699 /* Extract this shared object's name. */
700+ if (debug_solib)
701+ fprintf_unfiltered (gdb_stdlog,
702+ "svr4_current_sos: read LM_NAME\n");
703+
704 target_read_string (LM_NAME (new), &buffer,
705 SO_NAME_MAX_PATH_SIZE - 1, &errcode);
706 if (errcode != 0)
7566401a 707@@ -1101,63 +1336,76 @@ svr4_current_sos (void)
3a58abaf
AM
708 safe_strerror (errcode));
709 else
710 {
711- struct build_id *build_id;
7566401a
ER
712-
713- strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
714- new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
715- /* May get overwritten below. */
716- strcpy (new->so_name, new->so_original_name);
717-
718- build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new));
719- if (build_id != NULL)
3a58abaf
AM
720+ if (debug_solib)
721+ fprintf_unfiltered (gdb_stdlog,
722+ "svr4_current_sos: LM_NAME is <%s>\n",
723+ buffer);
724+ /* The name could be empty, in which case it is the
725+ system supplied DSO. */
726+ if (strcmp (buffer, "") == 0)
727+ free_so (new);
728+ else
7566401a
ER
729 {
730- char *name, *build_id_filename;
3a58abaf 731+ struct build_id *build_id;
7566401a 732+
3a58abaf
AM
733+ strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
734+ new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
735+ /* May get overwritten below. */
736+ strcpy (new->so_name, new->so_original_name);
737
7566401a
ER
738- /* Missing the build-id matching separate debug info file
739- would be handled while SO_NAME gets loaded. */
740- name = build_id_to_filename (build_id, &build_id_filename, 0);
741- if (name != NULL)
3a58abaf
AM
742+ build_id = build_id_addr_get (LM_DYNAMIC_FROM_LINK_MAP (new));
743+ if (build_id != NULL)
7566401a
ER
744 {
745- strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1);
746- new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
747- xfree (name);
3a58abaf
AM
748+ char *name, *build_id_filename;
749+
750+ /* Missing the build-id matching separate debug info file
751+ would be handled while SO_NAME gets loaded. */
752+ name = build_id_to_filename (build_id, &build_id_filename, 0);
753+ if (name != NULL)
754+ {
755+ strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1);
756+ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
757+ xfree (name);
758+ }
759+ else
7566401a
ER
760+ {
761+ debug_print_missing (new->so_name, build_id_filename);
762+
763+ /* In the case the main executable was found according to
764+ its build-id (from a core file) prevent loading
765+ a different build of a library with accidentally the
766+ same SO_NAME.
767+
768+ It suppresses bogus backtraces (and prints "??" there
769+ instead) if the on-disk files no longer match the
770+ running program version. */
771+
772+ if (symfile_objfile != NULL
773+ && (symfile_objfile->flags
774+ & OBJF_BUILD_ID_CORE_LOADED) != 0)
775+ new->so_name[0] = 0;
776+ }
3a58abaf
AM
777+
778+ xfree (build_id_filename);
779+ xfree (build_id);
7566401a
ER
780 }
781- else
782- {
783- debug_print_missing (new->so_name, build_id_filename);
3a58abaf 784
7566401a
ER
785- /* In the case the main executable was found according to
786- its build-id (from a core file) prevent loading
787- a different build of a library with accidentally the
788- same SO_NAME.
789-
790- It suppresses bogus backtraces (and prints "??" there
791- instead) if the on-disk files no longer match the
792- running program version. */
793-
794- if (symfile_objfile != NULL
795- && (symfile_objfile->flags
796- & OBJF_BUILD_ID_CORE_LOADED) != 0)
797- new->so_name[0] = 0;
3a58abaf 798+ if (debug_solib)
7566401a 799+ {
3a58abaf
AM
800+ fprintf_unfiltered (gdb_stdlog,
801+ "svr4_current_sos: Processing DSO: %s\n",
802+ new->so_name);
803+ fprintf_unfiltered (gdb_stdlog,
804+ "svr4_current_sos: first link entry %d\n",
805+ IGNORE_FIRST_LINK_MAP_ENTRY (new));
806 }
3a58abaf
AM
807
808- xfree (build_id_filename);
809- xfree (build_id);
810+ new->next = 0;
811+ *link_ptr = new;
812+ link_ptr = &new->next;
813 }
814 }
815- xfree (buffer);
816-
817- /* If this entry has no name, or its name matches the name
818- for the main executable, don't include it in the list. */
819- if (! new->so_name[0]
820- || match_main (new->so_name))
821- free_so (new);
822- else
823- {
824- new->next = 0;
825- *link_ptr = new;
826- link_ptr = &new->next;
827- }
828+ xfree (buffer);
829 }
830
831 /* On Solaris, the dynamic linker is not in the normal list of
7566401a 832@@ -1173,6 +1421,9 @@ svr4_current_sos (void)
3a58abaf
AM
833 if (head == NULL)
834 return svr4_default_sos ();
835
836+ if (debug_solib)
837+ fprintf_unfiltered (gdb_stdlog, "svr4_current_sos: ENDS %s\n", filename);
838+
839 return head;
840 }
841
7566401a 842@@ -1205,7 +1456,7 @@ svr4_fetch_objfile_link_map (struct objf
3a58abaf
AM
843 /* On some systems, the only way to recognize the link map entry for
844 the main executable file is by looking at its name. Return
845 non-zero iff SONAME matches one of the known main executable names. */
846-
847+#if 0
848 static int
849 match_main (char *soname)
850 {
7566401a 851@@ -1219,6 +1470,7 @@ match_main (char *soname)
3a58abaf
AM
852
853 return (0);
854 }
855+#endif
856
857 /* Return 1 if PC lies in the dynamic symbol resolution code of the
858 SVR4 run time loader. */
7566401a 859@@ -1370,15 +1622,29 @@ enable_break (struct svr4_info *info)
3a58abaf
AM
860 /* Find the program interpreter; if not found, warn the user and drop
861 into the old breakpoint at symbol code. */
862 interp_name = find_program_interpreter ();
863+
864+ if (debug_solib)
865+ fprintf_unfiltered (gdb_stdlog,
866+ "enable_break: search for .interp in %s\n",
867+ exec_bfd->filename);
868 if (interp_name)
869 {
870 CORE_ADDR load_addr = 0;
871+ CORE_ADDR load_addr_mask = -1L;
872 int load_addr_found = 0;
873 int loader_found_in_list = 0;
874 struct so_list *so;
875 bfd *tmp_bfd = NULL;
876 struct target_ops *tmp_bfd_target;
877 volatile struct gdb_exception ex;
878+ int arch_size;
879+
880+ /* For 32bit inferiors with 64bit GDB we may get LOAD_ADDR at 0xff......
881+ and thus overflowing its addition to the address while CORE_ADDR is
882+ 64bit producing 0x1........ address invalid across GDB. */
883+ arch_size = bfd_get_arch_size (exec_bfd);
884+ if (arch_size > 0 && arch_size < sizeof (1UL) * 8)
885+ load_addr_mask = (1UL << arch_size) - 1;
886
887 sym_addr = 0;
888
7566401a 889@@ -1395,6 +1661,9 @@ enable_break (struct svr4_info *info)
3a58abaf
AM
890 {
891 tmp_bfd = solib_bfd_open (interp_name);
892 }
893+ if (debug_solib)
894+ fprintf_unfiltered (gdb_stdlog,
895+ "enable_break: opening %s\n", interp_name);
896 if (tmp_bfd == NULL)
897 goto bkpt_at_symbol;
898
7566401a 899@@ -1452,16 +1721,16 @@ enable_break (struct svr4_info *info)
3a58abaf
AM
900 interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
901 if (interp_sect)
902 {
903- interp_text_sect_low =
904- bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
905+ interp_text_sect_low = (bfd_section_vma (tmp_bfd, interp_sect)
906+ + load_addr) & load_addr_mask;
907 interp_text_sect_high =
908 interp_text_sect_low + bfd_section_size (tmp_bfd, interp_sect);
909 }
910 interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt");
911 if (interp_sect)
912 {
913- interp_plt_sect_low =
914- bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
915+ interp_plt_sect_low = (bfd_section_vma (tmp_bfd, interp_sect)
916+ + load_addr) & load_addr_mask;
917 interp_plt_sect_high =
918 interp_plt_sect_low + bfd_section_size (tmp_bfd, interp_sect);
919 }
7566401a 920@@ -1496,7 +1765,7 @@ enable_break (struct svr4_info *info)
3a58abaf
AM
921
922 if (sym_addr != 0)
923 {
7566401a
ER
924- create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr);
925+ create_solib_event_breakpoint (target_gdbarch, (load_addr + sym_addr) & load_addr_mask);
3a58abaf
AM
926 xfree (interp_name);
927 return 1;
928 }
7566401a 929@@ -1769,6 +2038,9 @@ svr4_solib_create_inferior_hook (void)
3a58abaf
AM
930 while (tp->stop_signal != TARGET_SIGNAL_TRAP);
931 inf->stop_soon = NO_STOP_QUIETLY;
932 #endif /* defined(_SCO_DS) */
933+
7566401a
ER
934+ if (bfd_get_start_address (exec_bfd) != entry_point_address ())
935+ disable_breakpoints_before_startup ();
3a58abaf
AM
936 }
937
938 static void
7566401a 939@@ -1945,6 +2217,76 @@ svr4_lp64_fetch_link_map_offsets (void)
3a58abaf
AM
940
941 return lmp;
942 }
943+void
944+info_linkmap_command (char *cmd, int from_tty)
945+{
946+ CORE_ADDR lm;
7566401a 947+ struct svr4_info *info = get_svr4_info (PIDGET (inferior_ptid));
3a58abaf
AM
948+
949+ /* Make sure we've looked up the inferior's dynamic linker's base
950+ structure. */
7566401a 951+ if (! info->debug_base)
3a58abaf 952+ {
7566401a 953+ info->debug_base = locate_base (info);
3a58abaf
AM
954+
955+ /* If we can't find the dynamic linker's base structure, this
956+ must not be a dynamically linked executable. Hmm. */
7566401a 957+ if (! info->debug_base)
3a58abaf
AM
958+ {
959+ if (debug_solib)
960+ fprintf_unfiltered (gdb_stdlog,
961+ "svr4_print_linkmap: no DT_DEBUG found in %s -- return now\n",
962+ exec_bfd->filename);
963+ return;
964+ }
965+ }
966+
967+ /* Walk the inferior's link map list, and print the info. */
968+
7566401a 969+ lm = solib_svr4_r_map (info);
3a58abaf
AM
970+ while (lm)
971+ {
972+ int errcode;
973+ char *buffer;
974+ CORE_ADDR load_addr;
975+
976+ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
977+ struct so_list *new
978+ = (struct so_list *) xmalloc (sizeof (struct so_list));
979+ struct cleanup *old_chain = make_cleanup (xfree, new);
980+
981+ memset (new, 0, sizeof (*new));
982+
983+ new->lm_info = xmalloc (sizeof (struct lm_info));
984+ make_cleanup (xfree, new->lm_info);
985+
986+ new->lm_info->lm = xmalloc (lmo->link_map_size);
987+ make_cleanup (xfree, new->lm_info->lm);
988+ memset (new->lm_info->lm, 0, lmo->link_map_size);
989+
990+ if (debug_solib)
991+ fprintf_unfiltered (gdb_stdlog,
7566401a 992+ "svr4_print_linkmap: read lm at %s\n", paddress (target_gdbarch, lm));
3a58abaf
AM
993+ read_memory (lm, new->lm_info->lm, lmo->link_map_size);
994+
995+ lm = LM_NEXT (new);
996+
997+ /* Load address. */
998+ load_addr = LM_ADDR_CHECK (new, NULL);
999+ /* Shared object's name. */
1000+ target_read_string (LM_NAME (new), &buffer,
1001+ SO_NAME_MAX_PATH_SIZE - 1, &errcode);
1002+ make_cleanup (xfree, buffer);
1003+ if (errcode != 0)
1004+ {
1005+ warning ("svr4_print_linkmap: Can't read pathname for load map: %s\n",
1006+ safe_strerror (errcode));
1007+ }
7566401a 1008+ fprintf_filtered (gdb_stdout, "%-8s %-30s\n", paddress (target_gdbarch, load_addr), buffer);
3a58abaf
AM
1009+ do_cleanups (old_chain);
1010+ }
1011+}
1012+
1013 \f
1014
1015 struct target_so_ops svr4_so_ops;
7566401a 1016@@ -1985,4 +2327,7 @@ _initialize_svr4_solib (void)
3a58abaf 1017 svr4_so_ops.same = svr4_same;
7566401a
ER
1018
1019 observer_attach_inferior_exit (solib_svr4_inferior_exit);
3a58abaf
AM
1020+
1021+ add_info ("linkmap", info_linkmap_command,
1022+ "Display the inferior's linkmap.");
1023 }
7566401a 1024Index: gdb-6.8.91.20090925/gdb/solib.c
3a58abaf 1025===================================================================
7566401a
ER
1026--- gdb-6.8.91.20090925.orig/gdb/solib.c 2009-09-25 10:25:38.000000000 +0200
1027+++ gdb-6.8.91.20090925/gdb/solib.c 2009-09-25 10:25:45.000000000 +0200
1028@@ -82,6 +82,8 @@ set_solib_ops (struct gdbarch *gdbarch,
3a58abaf
AM
1029
1030 /* external data declarations */
1031
1032+int debug_solib;
1033+
1034 /* FIXME: gdbarch needs to control this variable, or else every
1035 configuration needs to call set_solib_ops. */
1036 struct target_so_ops *current_target_so_ops;
7566401a 1037@@ -105,6 +107,8 @@ The search path for loading non-absolute
3a58abaf
AM
1038 value);
1039 }
1040
1041+void add_to_target_sections (int, struct target_ops *, struct so_list *);
1042+
1043 /*
1044
1045 GLOBAL FUNCTION
7566401a 1046@@ -449,14 +453,38 @@ symbol_add_stub (struct so_list *so, int
3a58abaf
AM
1047 /* Have we already loaded this shared object? */
1048 ALL_OBJFILES (so->objfile)
1049 {
1050- if (strcmp (so->objfile->name, so->so_name) == 0)
1051+ /* Found an already loaded shared library. */
1052+ if (strcmp (so->objfile->name, so->so_name) == 0
1053+ && !so->main)
7566401a 1054+ return;
3a58abaf
AM
1055+ /* Found an already loaded main executable. This could happen in
1056+ two circumstances.
1057+ First case: the main file has already been read in
1058+ as the first thing that gdb does at startup, and the file
1059+ hasn't been relocated properly yet. Therefor we need to read
1060+ it in with the proper section info.
1061+ Second case: it has been read in with the correct relocation,
1062+ and therefore we need to skip it. */
1063+ if (strcmp (so->objfile->name, so->so_name) == 0
1064+ && so->main
1065+ && so->main_relocated)
7566401a 1066 return;
3a58abaf
AM
1067 }
1068
1069 sap = build_section_addr_info_from_section_table (so->sections,
1070 so->sections_end);
1071
7566401a 1072- so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED);
3a58abaf
AM
1073+ if (so->main)
1074+ {
1075+ if (debug_solib)
1076+ fprintf_unfiltered (gdb_stdlog,
1077+ "symbol_add_stub: adding symbols for main\n");
7566401a 1078+ so->objfile = symbol_file_add_from_bfd (so->abfd, (flags & ~SYMFILE_VERBOSE) | SYMFILE_MAINLINE, sap, 0);
3a58abaf
AM
1079+ so->main_relocated = 1;
1080+ }
1081+ else
7566401a 1082+ so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED);
3a58abaf
AM
1083+
1084 free_section_addr_info (sap);
1085
7566401a
ER
1086 return;
1087@@ -596,6 +624,10 @@ update_solib_list (int from_tty, struct
3a58abaf
AM
1088 }
1089 else
1090 {
1091+ if (debug_solib)
1092+ fprintf_unfiltered (gdb_stdlog,
1093+ "update_solib_list: compare gdb:%s and inferior:%s\n",
1094+ gdb->so_original_name, i->so_original_name);
1095 if (! strcmp (gdb->so_original_name, i->so_original_name))
1096 break;
1097 }
7566401a 1098@@ -650,18 +682,7 @@ update_solib_list (int from_tty, struct
3a58abaf
AM
1099 /* Fill in the rest of each of the `struct so_list' nodes. */
1100 for (i = inferior; i; i = i->next)
1101 {
1102- i->from_tty = from_tty;
1103-
1104- /* Fill in the rest of the `struct so_list' node. */
1105- catch_errors (solib_map_sections, i,
1106- "Error while mapping shared library sections:\n",
1107- RETURN_MASK_ALL);
1108-
7566401a
ER
1109- /* Add the shared object's sections to the current set of
1110- file section tables. Do this immediately after mapping
1111- the object so that later nodes in the list can query this
1112- object, as is needed in solib-osf.c. */
1113- add_target_sections (i->sections, i->sections_end);
1114+ add_to_target_sections (from_tty, target, i);
3a58abaf
AM
1115
1116 /* Notify any observer that the shared object has been
1117 loaded now that we've added it to GDB's tables. */
7566401a 1118@@ -771,6 +792,32 @@ solib_add (char *pattern, int from_tty,
3a58abaf
AM
1119 }
1120 }
1121
1122+void
1123+add_to_target_sections (int from_tty, struct target_ops *target, struct so_list *solib)
1124+{
1125+ /* If this is set, then the sections have been already added to the
1126+ target list. */
1127+ if (solib->main)
1128+ return;
1129+
1130+ solib->from_tty = from_tty;
1131+
1132+ /* Fill in the rest of the `struct so_list' node. */
1133+ catch_errors (solib_map_sections, solib,
7566401a
ER
1134+ "Error while mapping shared library sections:\n",
1135+ RETURN_MASK_ALL);
1136+
1137+ if (debug_solib)
1138+ fprintf_unfiltered (gdb_stdlog,
1139+ "add_to_target_sections: add %s to to_sections\n",
1140+ solib->so_original_name);
1141+
1142+ /* Add the shared object's sections to the current set of
1143+ file section tables. Do this immediately after mapping
1144+ the object so that later nodes in the list can query this
1145+ object, as is needed in solib-osf.c. */
1146+ add_target_sections (solib->sections, solib->sections_end);
3a58abaf
AM
1147+}
1148
1149 /*
1150
7566401a 1151@@ -1189,4 +1236,12 @@ This takes precedence over the environme
3a58abaf
AM
1152 reload_shared_libraries,
1153 show_solib_search_path,
1154 &setlist, &showlist);
1155+
1156+ add_setshow_boolean_cmd ("solib", no_class, &debug_solib,
1157+ _("\
1158+Set debugging of GNU/Linux shlib module.\n"), _("\
1159+Show debugging status of GNU/Linux shlib module.\n"), _("\
1160+Enables printf debugging output of GNU/Linux shlib module.\n"),
1161+ NULL, NULL,
1162+ &setdebuglist, &showdebuglist);
1163 }
7566401a 1164Index: gdb-6.8.91.20090925/gdb/solist.h
3a58abaf 1165===================================================================
7566401a
ER
1166--- gdb-6.8.91.20090925.orig/gdb/solist.h 2009-09-25 10:25:38.000000000 +0200
1167+++ gdb-6.8.91.20090925/gdb/solist.h 2009-09-25 10:25:45.000000000 +0200
3a58abaf
AM
1168@@ -61,6 +61,8 @@ struct so_list
1169 bfd *abfd;
1170 char symbols_loaded; /* flag: symbols read in yet? */
1171 char from_tty; /* flag: print msgs? */
1172+ char main; /* flag: is this the main executable? */
1173+ char main_relocated; /* flag: has it been relocated yet? */
1174 struct objfile *objfile; /* objfile for loaded lib */
7566401a
ER
1175 struct target_section *sections;
1176 struct target_section *sections_end;
1177@@ -147,4 +149,10 @@ struct symbol *solib_global_lookup (cons
1178 const char *name,
3a58abaf
AM
1179 const domain_enum domain);
1180
1181+/* Add the list of sections in so_list to the target to_sections. */
1182+extern void add_to_target_sections (int, struct target_ops *, struct so_list *);
1183+
1184+/* Controls the printing of debugging output. */
1185+extern int debug_solib;
1186+
1187 #endif
7566401a 1188Index: gdb-6.8.91.20090925/gdb/symfile-mem.c
3a58abaf 1189===================================================================
7566401a
ER
1190--- gdb-6.8.91.20090925.orig/gdb/symfile-mem.c 2009-09-25 10:25:38.000000000 +0200
1191+++ gdb-6.8.91.20090925/gdb/symfile-mem.c 2009-09-25 10:25:45.000000000 +0200
1192@@ -115,7 +115,7 @@ symbol_file_add_from_memory (struct bfd
1193 ++i;
3a58abaf
AM
1194 }
1195
7566401a
ER
1196- objf = symbol_file_add_from_bfd (nbfd, from_tty ? SYMFILE_VERBOSE : 0,
1197+ objf = symbol_file_add_from_bfd (nbfd, (from_tty ? SYMFILE_VERBOSE : 0) | SYMFILE_MAINLINE2_BOTH,
1198 sai, OBJF_SHARED);
3a58abaf
AM
1199
1200 /* This might change our ideas about frames already looked at. */
7566401a 1201Index: gdb-6.8.91.20090925/gdb/symfile.c
3a58abaf 1202===================================================================
7566401a
ER
1203--- gdb-6.8.91.20090925.orig/gdb/symfile.c 2009-09-25 10:25:39.000000000 +0200
1204+++ gdb-6.8.91.20090925/gdb/symfile.c 2009-09-25 10:25:45.000000000 +0200
1205@@ -49,6 +49,7 @@
3a58abaf
AM
1206 #include "readline/readline.h"
1207 #include "gdb_assert.h"
1208 #include "block.h"
1209+#include "varobj.h"
1210 #include "observer.h"
1211 #include "exec.h"
1212 #include "parser-defs.h"
7566401a 1213@@ -779,7 +780,7 @@ syms_from_objfile (struct objfile *objfi
3a58abaf
AM
1214
1215 /* Now either addrs or offsets is non-zero. */
1216
1217- if (mainline)
7566401a 1218+ if ((add_flags & SYMFILE_MAINLINE) && !(add_flags & SYMFILE_MAINLINE2_ONLY))
3a58abaf
AM
1219 {
1220 /* We will modify the main symbol table, make sure that all its users
1221 will be cleaned up if an error occurs during symbol reading. */
7566401a 1222@@ -807,7 +808,7 @@ syms_from_objfile (struct objfile *objfi
3a58abaf
AM
1223
1224 We no longer warn if the lowest section is not a text segment (as
1225 happens for the PA64 port. */
1226- if (!mainline && addrs && addrs->other[0].name)
1227+ if (/*!mainline &&*/ addrs && addrs->other[0].name)
1228 {
1229 asection *lower_sect;
1230 asection *sect;
7566401a
ER
1231@@ -890,7 +891,7 @@ syms_from_objfile (struct objfile *objfi
1232 init_objfile_sect_indices (objfile);
1233 }
1234
1235- (*objfile->sf->sym_read) (objfile, mainline);
1236+ (*objfile->sf->sym_read) (objfile, add_flags & SYMFILE_MAINLINE2_ONLY ? 2 : (add_flags & SYMFILE_MAINLINE ? 1 : 0));
1237
1238 /* Discard cleanups as symbol reading was successful. */
1239
1240@@ -909,17 +910,22 @@ new_symfile_objfile (struct objfile *obj
3a58abaf
AM
1241 /* If this is the main symbol file we have to clean up all users of the
1242 old main symbol file. Otherwise it is sufficient to fixup all the
1243 breakpoints that may have been redefined by this symbol file. */
7566401a
ER
1244- if (add_flags & SYMFILE_MAINLINE)
1245+ if (add_flags & SYMFILE_MAINLINE && !(add_flags & SYMFILE_MAINLINE2_ONLY))
3a58abaf
AM
1246 {
1247 /* OK, make it the "real" symbol file. */
1248 symfile_objfile = objfile;
1249
1250 clear_symtab_users ();
1251 }
7566401a
ER
1252- else if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0)
1253+ else if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0
1254+ && (add_flags & SYMFILE_MAINLINE2_BOTH) == 0)
3a58abaf
AM
1255 {
1256 breakpoint_re_set ();
1257 }
1258+ else
1259+ {
1260+ /* Don't reset breakpoints or it will screw up PIE. */
1261+ }
1262
1263 /* We're done reading the symbol file; finish off complaints. */
7566401a
ER
1264 clear_complaints (&symfile_complaints, 0, add_flags & SYMFILE_VERBOSE);
1265@@ -973,7 +979,7 @@ symbol_file_add_with_addrs_or_offsets (b
3a58abaf
AM
1266 /* Give user a chance to burp if we'd be
1267 interactively wiping out any existing symbols. */
1268
7566401a
ER
1269- if ((add_flags & SYMFILE_MAINLINE)
1270+ if ((add_flags & SYMFILE_MAINLINE) && !(add_flags & SYMFILE_MAINLINE2_ONLY)
1271 && (have_full_symbols () || have_partial_symbols ())
3a58abaf
AM
1272 && from_tty
1273 && (have_full_symbols () || have_partial_symbols ())
7566401a 1274@@ -1163,6 +1169,9 @@ symbol_file_clear (int from_tty)
3a58abaf
AM
1275 symfile_objfile->name)
1276 : !query (_("Discard symbol table? "))))
1277 error (_("Not confirmed."));
1278+#ifdef CLEAR_SOLIB
1279+ CLEAR_SOLIB ();
1280+#endif
3a58abaf 1281
7566401a
ER
1282 free_all_objfiles ();
1283
1284@@ -3367,6 +3376,8 @@ reread_symbols (void)
3a58abaf
AM
1285 /* Discard cleanups as symbol reading was successful. */
1286 discard_cleanups (old_cleanups);
1287
1288+ init_entry_point_info (objfile);
1289+
1290 /* If the mtime has changed between the time we set new_modtime
1291 and now, we *want* this to be out of date, so don't call stat
1292 again now. */
7566401a 1293Index: gdb-6.8.91.20090925/gdb/target.h
3a58abaf 1294===================================================================
7566401a
ER
1295--- gdb-6.8.91.20090925.orig/gdb/target.h 2009-09-25 10:25:38.000000000 +0200
1296+++ gdb-6.8.91.20090925/gdb/target.h 2009-09-25 10:25:45.000000000 +0200
1297@@ -545,7 +545,7 @@ struct target_ops
3a58abaf
AM
1298 Return -1 if there is insufficient buffer for a whole entry.
1299 Return 1 if an entry was read into *TYPEP and *VALP. */
1300 int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr,
1301- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
1302+ gdb_byte *endptr, ULONGEST *typep, CORE_ADDR *valp);
1303
1304 /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
1305 sequence of bytes in PATTERN with length PATTERN_LEN.
7566401a
ER
1306Index: gdb-6.8.91.20090925/gdb/symfile.h
1307===================================================================
1308--- gdb-6.8.91.20090925.orig/gdb/symfile.h 2009-09-25 10:25:39.000000000 +0200
1309+++ gdb-6.8.91.20090925/gdb/symfile.h 2009-09-25 10:25:45.000000000 +0200
1310@@ -229,7 +229,13 @@ enum symfile_add_flags
1311 SYMFILE_MAINLINE = 1 << 2,
1312
1313 /* Do not call breakpoint_re_set when adding this symbol file. */
1314- SYMFILE_DEFER_BP_RESET = 1 << 3
1315+ SYMFILE_DEFER_BP_RESET = 1 << 3,
1316+
1317+ /* Red Hat PIE patch: Like SYMFILE_MAINLINE but for mainline == 2.
1318+ Former code was checking `if (mainline)' being satisfied both by
1319+ standard 1 and rare 2, simulate it here. */
1320+ SYMFILE_MAINLINE2_ONLY = 1 << 4,
1321+ SYMFILE_MAINLINE2_BOTH = SYMFILE_MAINLINE2_ONLY | SYMFILE_MAINLINE
1322 };
1323
1324 extern void syms_from_objfile (struct objfile *,
1325Index: gdb-6.8.91.20090925/gdb/infcmd.c
1326===================================================================
1327--- gdb-6.8.91.20090925.orig/gdb/infcmd.c 2009-09-25 10:25:39.000000000 +0200
1328+++ gdb-6.8.91.20090925/gdb/infcmd.c 2009-09-25 10:25:45.000000000 +0200
1329@@ -2308,6 +2308,9 @@ attach_command_post_wait (char *args, in
1330
1331 post_create_inferior (&current_target, from_tty);
1332
1333+ /* Undo the disable from post_create_inferior. */
1334+ enable_breakpoints_after_startup ();
1335+
1336 /* Install inferior's terminal modes. */
1337 target_terminal_inferior ();
1338
1339Index: gdb-6.8.91.20090925/gdb/linux-tdep.c
1340===================================================================
1341--- gdb-6.8.91.20090925.orig/gdb/linux-tdep.c 2009-08-04 22:41:13.000000000 +0200
1342+++ gdb-6.8.91.20090925/gdb/linux-tdep.c 2009-09-25 10:25:45.000000000 +0200
1343@@ -163,5 +163,7 @@ in this session.\n"));
1344 void
1345 _initialize_linux_tdep (void)
1346 {
1347+#if 0 /* gdb-6.3-pie-20050110.patch */
1348 observer_attach_executable_changed (check_is_pie_binary);
1349+#endif
1350 }
This page took 0.448385 seconds and 4 git commands to generate.