1
diff -urpN gdb-6.6.orig/bfd/elf32-ppc.c gdb-6.6/bfd/elf32-ppc.c
2
--- gdb-6.6.orig/bfd/elf32-ppc.c 2006-11-03 11:28:09.000000000 +1030
3
+++ gdb-6.6/bfd/elf32-ppc.c 2007-02-28 21:27:39.000000000 +1030
5
suggestions from the in-progress Embedded PowerPC ABI, and that
6
information may also not match. */
12
@@ -1813,6 +1814,52 @@ ppc_elf_grok_psinfo (bfd *abfd, Elf_Inte
17
+ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, ...)
29
+ va_start (ap, note_type);
30
+ memset (data, 0, 32);
31
+ strncpy (data + 32, va_arg (ap, const char *), 16);
32
+ strncpy (data + 48, va_arg (ap, const char *), 80);
34
+ return elfcore_write_note (abfd, buf, bufsiz,
35
+ "CORE", note_type, data, sizeof (data));
46
+ va_start (ap, note_type);
47
+ memset (data, 0, 72);
48
+ pid = va_arg (ap, long);
49
+ bfd_put_32 (abfd, pid, data + 24);
50
+ cursig = va_arg (ap, int);
51
+ bfd_put_16 (abfd, cursig, data + 12);
52
+ greg = va_arg (ap, const void *);
53
+ memcpy (data + 72, greg, 192);
54
+ memset (data + 264, 0, 4);
56
+ return elfcore_write_note (abfd, buf, bufsiz,
57
+ "CORE", note_type, data, sizeof (data));
62
/* Return address for Ith PLT stub in section PLT, for relocation REL
63
or (bfd_vma) -1 if it should not be included. */
65
@@ -7473,6 +7520,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou
66
#define elf_backend_additional_program_headers ppc_elf_additional_program_headers
67
#define elf_backend_grok_prstatus ppc_elf_grok_prstatus
68
#define elf_backend_grok_psinfo ppc_elf_grok_psinfo
69
+#define elf_backend_write_core_note ppc_elf_write_core_note
70
#define elf_backend_reloc_type_class ppc_elf_reloc_type_class
71
#define elf_backend_begin_write_processing ppc_elf_begin_write_processing
72
#define elf_backend_final_write_processing ppc_elf_final_write_processing
73
diff -urpN gdb-6.6.orig/bfd/elf64-ppc.c gdb-6.6/bfd/elf64-ppc.c
74
--- gdb-6.6.orig/bfd/elf64-ppc.c 2006-11-07 14:04:52.000000000 +1030
75
+++ gdb-6.6/bfd/elf64-ppc.c 2007-02-28 21:27:39.000000000 +1030
77
http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi.txt, and
78
http://www.linuxbase.org/spec/ELF/ppc64/spec/book1.html */
84
@@ -84,6 +85,7 @@ static bfd_vma opd_entry_value
85
#define elf_backend_object_p ppc64_elf_object_p
86
#define elf_backend_grok_prstatus ppc64_elf_grok_prstatus
87
#define elf_backend_grok_psinfo ppc64_elf_grok_psinfo
88
+#define elf_backend_write_core_note ppc64_elf_write_core_note
89
#define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections
90
#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol
91
#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook
92
@@ -2483,6 +2485,53 @@ ppc64_elf_grok_psinfo (bfd *abfd, Elf_In
97
+ppc64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
110
+ va_start (ap, note_type);
111
+ memset (data, 0, 40);
112
+ strncpy (data + 40, va_arg (ap, const char *), 16);
113
+ strncpy (data + 56, va_arg (ap, const char *), 80);
115
+ return elfcore_write_note (abfd, buf, bufsiz,
116
+ "CORE", note_type, data, sizeof (data));
127
+ va_start (ap, note_type);
128
+ memset (data, 0, 112);
129
+ pid = va_arg (ap, long);
130
+ bfd_put_32 (abfd, pid, data + 32);
131
+ cursig = va_arg (ap, int);
132
+ bfd_put_16 (abfd, cursig, data + 12);
133
+ greg = va_arg (ap, const void *);
134
+ memcpy (data + 112, greg, 384);
135
+ memset (data + 496, 0, 8);
137
+ return elfcore_write_note (abfd, buf, bufsiz,
138
+ "CORE", note_type, data, sizeof (data));
143
/* Merge backend specific data from an object file to the output
144
object file when linking. */
146
diff -urpN gdb-6.6.orig/bfd/elf-bfd.h gdb-6.6/bfd/elf-bfd.h
147
--- gdb-6.6.orig/bfd/elf-bfd.h 2006-11-03 01:50:31.000000000 +1030
148
+++ gdb-6.6/bfd/elf-bfd.h 2007-02-28 21:27:39.000000000 +1030
149
@@ -943,15 +943,19 @@ struct elf_backend_data
150
(asection *, Elf_Internal_Rela *);
152
/* This function, if defined, is called when an NT_PRSTATUS note is found
155
bfd_boolean (*elf_backend_grok_prstatus)
156
(bfd *, Elf_Internal_Note *);
158
/* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
159
- note is found in a core file. */
160
+ note is found in a core file. */
161
bfd_boolean (*elf_backend_grok_psinfo)
162
(bfd *, Elf_Internal_Note *);
164
+ /* This function, if defined, is called to write a note to a corefile. */
165
+ char *(*elf_backend_write_core_note)
166
+ (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
168
/* Functions to print VMAs. Special code to handle 64 bit ELF files. */
169
void (* elf_backend_sprintf_vma)
170
(bfd *, char *, bfd_vma);
171
diff -urpN gdb-6.6.orig/bfd/elf.c gdb-6.6/bfd/elf.c
172
--- gdb-6.6.orig/bfd/elf.c 2007-02-28 21:25:44.000000000 +1030
173
+++ gdb-6.6/bfd/elf.c 2007-02-28 21:27:39.000000000 +1030
174
@@ -8183,22 +8183,52 @@ elfcore_write_prpsinfo (bfd *abfd,
179
- char *note_name = "CORE";
180
+ const char *note_name = "CORE";
181
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
183
+ if (bed->elf_backend_write_core_note != NULL)
186
+ ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
187
+ NT_PRPSINFO, fname, psargs);
192
+#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
193
+ if (bed->s->elfclass == ELFCLASS32)
195
+#if defined (HAVE_PSINFO32_T)
197
+ int note_type = NT_PSINFO;
200
+ int note_type = NT_PRPSINFO;
203
+ memset (&data, 0, sizeof (data));
204
+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
205
+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
206
+ return elfcore_write_note (abfd, buf, bufsiz,
207
+ note_name, note_type, &data, sizeof (data));
212
#if defined (HAVE_PSINFO_T)
214
- note_type = NT_PSINFO;
216
+ int note_type = NT_PSINFO;
219
- note_type = NT_PRPSINFO;
221
+ int note_type = NT_PRPSINFO;
224
- memset (&data, 0, sizeof (data));
225
- strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
226
- strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
227
- return elfcore_write_note (abfd, buf, bufsiz,
228
- note_name, note_type, &data, sizeof (data));
229
+ memset (&data, 0, sizeof (data));
230
+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
231
+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
232
+ return elfcore_write_note (abfd, buf, bufsiz,
233
+ note_name, note_type, &data, sizeof (data));
236
#endif /* PSINFO_T or PRPSINFO_T */
238
@@ -8211,15 +8241,43 @@ elfcore_write_prstatus (bfd *abfd,
243
- char *note_name = "CORE";
244
+ const char *note_name = "CORE";
245
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
247
- memset (&prstat, 0, sizeof (prstat));
248
- prstat.pr_pid = pid;
249
- prstat.pr_cursig = cursig;
250
- memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
251
- return elfcore_write_note (abfd, buf, bufsiz,
252
- note_name, NT_PRSTATUS, &prstat, sizeof (prstat));
253
+ if (bed->elf_backend_write_core_note != NULL)
256
+ ret = (*bed->elf_backend_write_core_note) (abfd, buf, bufsiz,
258
+ pid, cursig, gregs);
263
+#if defined (HAVE_PRSTATUS32_T)
264
+ if (bed->s->elfclass == ELFCLASS32)
266
+ prstatus32_t prstat;
268
+ memset (&prstat, 0, sizeof (prstat));
269
+ prstat.pr_pid = pid;
270
+ prstat.pr_cursig = cursig;
271
+ memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
272
+ return elfcore_write_note (abfd, buf, bufsiz, note_name,
273
+ NT_PRSTATUS, &prstat, sizeof (prstat));
280
+ memset (&prstat, 0, sizeof (prstat));
281
+ prstat.pr_pid = pid;
282
+ prstat.pr_cursig = cursig;
283
+ memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
284
+ return elfcore_write_note (abfd, buf, bufsiz, note_name,
285
+ NT_PRSTATUS, &prstat, sizeof (prstat));
288
#endif /* HAVE_PRSTATUS_T */
290
@@ -8233,7 +8291,7 @@ elfcore_write_lwpstatus (bfd *abfd,
294
- char *note_name = "CORE";
295
+ const char *note_name = "CORE";
297
memset (&lwpstat, 0, sizeof (lwpstat));
298
lwpstat.pr_lwpid = pid >> 16;
299
@@ -8263,14 +8321,31 @@ elfcore_write_pstatus (bfd *abfd,
300
int cursig ATTRIBUTE_UNUSED,
301
const void *gregs ATTRIBUTE_UNUSED)
304
- char *note_name = "CORE";
305
+ const char *note_name = "CORE";
306
+#if defined (HAVE_PSTATUS32_T)
307
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
309
- memset (&pstat, 0, sizeof (pstat));
310
- pstat.pr_pid = pid & 0xffff;
311
- buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
312
- NT_PSTATUS, &pstat, sizeof (pstat));
314
+ if (bed->s->elfclass == ELFCLASS32)
318
+ memset (&pstat, 0, sizeof (pstat));
319
+ pstat.pr_pid = pid & 0xffff;
320
+ buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
321
+ NT_PSTATUS, &pstat, sizeof (pstat));
329
+ memset (&pstat, 0, sizeof (pstat));
330
+ pstat.pr_pid = pid & 0xffff;
331
+ buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
332
+ NT_PSTATUS, &pstat, sizeof (pstat));
336
#endif /* HAVE_PSTATUS_T */
338
@@ -8281,7 +8356,7 @@ elfcore_write_prfpreg (bfd *abfd,
342
- char *note_name = "CORE";
343
+ const char *note_name = "CORE";
344
return elfcore_write_note (abfd, buf, bufsiz,
345
note_name, NT_FPREGSET, fpregs, size);
347
diff -urpN gdb-6.6.orig/bfd/elfxx-target.h gdb-6.6/bfd/elfxx-target.h
348
--- gdb-6.6.orig/bfd/elfxx-target.h 2006-10-17 23:11:46.000000000 +0930
349
+++ gdb-6.6/bfd/elfxx-target.h 2007-02-28 21:27:39.000000000 +1030
351
#ifndef elf_backend_grok_psinfo
352
#define elf_backend_grok_psinfo NULL
354
+#ifndef elf_backend_write_core_note
355
+#define elf_backend_write_core_note NULL
357
#ifndef elf_backend_sprintf_vma
358
#define elf_backend_sprintf_vma _bfd_elf_sprintf_vma
360
@@ -632,6 +635,7 @@ static struct elf_backend_data elfNN_bed
361
elf_backend_count_relocs,
362
elf_backend_grok_prstatus,
363
elf_backend_grok_psinfo,
364
+ elf_backend_write_core_note,
365
elf_backend_sprintf_vma,
366
elf_backend_fprintf_vma,
367
elf_backend_reloc_type_class,