This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
FYI: patches for powerpc-aix...
- From: Joel Brobecker <brobecker at adacore dot com>
- To: binutils at sourceware dot org
- Cc: David Edelsohn <dje dot gcc at gmail dot com>, Tristan Gingold <gingold at adacore dot com>
- Date: Mon, 18 Feb 2013 15:05:28 -0800
- Subject: FYI: patches for powerpc-aix...
Hello,
Re: DWARF support with GNU as/ld on AIX:
http://sourceware.org/ml/binutils/2011-04/msg00250.html
http://www.sourceware.org/ml/gdb/2013-01/msg00030.html
I have been spending some time trying to gather and test our patches.
Unfortunately, I am running out of time for this week, and will
probably not be able to complete this task until later. Everything
tested fine when applying the patches to the sources as of Oct 18,
but I get an abort in gas with today's HEAD:
/tmp//ccY5Nx8U.s: Assembler messages:
/tmp//ccY5Nx8U.s:241: Internal error, aborting at /homes/brobecke/act/binutils/binutils-head/gas/config/tc-ppc.c line 3319 in md_assemble
Please report this bug.
gnatmake: *** link failed.
I had a quick look at the code in question, and my guess is that
it is not something that would be very hard to fix.
In the meantime, attached are the patches I have identified, in case
someone is interested. I will send a proper submission after I've
fixed the abort and tested them properly. The description of each
patch will also be provided then. Comments and suggestions are
of course always welcome.
--
Joel
>From 2e3730e95ff788204e58e6fff0dc59bd96bb983d Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Thu, 14 Feb 2013 23:53:25 +0100
Subject: [PATCH 1/5] AIX: add DWARF support
* bfd/coff-rs6000.c (xcoff_dwsect_names): Add .dwframe,
.dwloc, .dwmacif and .dwmacro.
* bfd/libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Set to 12.
* xcofflink.c (xcoff_mark): Mark all debugging symbols.
(bfd_xcoff_size_dynamic_sections): Mark all debugging sections.
(xcoff_link_input_bfd): Gah???
* gas/config/tc-ppc.c (ppc_named_section): Add handling
of DWARF sections.
---
bfd/coff-rs6000.c | 6 ++++-
bfd/libxcoff.h | 2 +-
bfd/xcofflink.c | 65 +++++++++++++++++++++++++++++---------------------
gas/config/tc-ppc.c | 29 ++++++++++++++++++++++-
4 files changed, 72 insertions(+), 30 deletions(-)
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 0945aca..9388ce3 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -3916,7 +3916,11 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
{ SSUBTYP_DWARNGE, ".dwarnge", TRUE },
{ SSUBTYP_DWABREV, ".dwabrev", FALSE },
{ SSUBTYP_DWSTR, ".dwstr", TRUE },
- { SSUBTYP_DWRNGES, ".dwrnges", TRUE }
+ { SSUBTYP_DWRNGES, ".dwrnges", TRUE },
+ { 0x47000000, ".dwframe", TRUE },
+ { 0x47010000, ".dwloc", TRUE },
+ { 0x47020000, ".dwmacif", FALSE },
+ { 0x47030000, ".dwmacro", FALSE }
};
static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h
index 3f66524..4700db4 100644
--- a/bfd/libxcoff.h
+++ b/bfd/libxcoff.h
@@ -251,7 +251,7 @@ struct xcoff_dwsect_name {
/* Number of entries in the array. The number is known and public so that user
can 'extend' this array by index. */
-#define XCOFF_DWSECT_NBR_NAMES 8
+#define XCOFF_DWSECT_NBR_NAMES 12
/* The dwarf sections array. */
extern const struct xcoff_dwsect_name
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index e769e03..2bd2018 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -2890,8 +2890,7 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
sec->flags |= SEC_MARK;
if (sec->owner->xvec == info->output_bfd->xvec
- && coff_section_data (sec->owner, sec) != NULL
- && xcoff_section_data (sec->owner, sec) != NULL)
+ && coff_section_data (sec->owner, sec) != NULL)
{
struct xcoff_link_hash_entry **syms;
struct internal_reloc *rel, *relend;
@@ -2899,18 +2898,21 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
unsigned long i, first, last;
/* Mark all the symbols in this section. */
- syms = obj_xcoff_sym_hashes (sec->owner);
- csects = xcoff_data (sec->owner)->csects;
- first = xcoff_section_data (sec->owner, sec)->first_symndx;
- last = xcoff_section_data (sec->owner, sec)->last_symndx;
- for (i = first; i <= last; i++)
- if (csects[i] == sec
- && syms[i] != NULL
- && (syms[i]->flags & XCOFF_MARK) == 0)
- {
- if (!xcoff_mark_symbol (info, syms[i]))
- return FALSE;
- }
+ if (xcoff_section_data (sec->owner, sec) != NULL)
+ {
+ syms = obj_xcoff_sym_hashes (sec->owner);
+ csects = xcoff_data (sec->owner)->csects;
+ first = xcoff_section_data (sec->owner, sec)->first_symndx;
+ last = xcoff_section_data (sec->owner, sec)->last_symndx;
+ for (i = first; i <= last; i++)
+ if (csects[i] == sec
+ && syms[i] != NULL
+ && (syms[i]->flags & XCOFF_MARK) == 0)
+ {
+ if (!xcoff_mark_symbol (info, syms[i]))
+ return FALSE;
+ }
+ }
/* Look through the section relocs. */
if ((sec->flags & SEC_RELOC) != 0
@@ -2953,7 +2955,8 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
/* See if this reloc needs to be copied into the .loader
section. */
- if (xcoff_need_ldrel_p (info, rel, h))
+ if ((sec->flags & SEC_DEBUGGING) == 0
+ && xcoff_need_ldrel_p (info, rel, h))
{
++xcoff_hash_table (info)->ldrel_count;
if (h != NULL)
@@ -3748,6 +3751,17 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
if (ldinfo.failed)
goto error_return;
}
+ /* Mark all debugging sections. */
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ {
+ asection *o;
+
+ for (o = sub->sections; o != NULL; o = o->next)
+ if ((o->flags & SEC_DEBUGGING) != 0
+ && (o->flags & SEC_MARK) == 0
+ && ! xcoff_mark (info, o))
+ goto error_return;
+ }
xcoff_sweep (info);
xcoff_hash_table (info)->gc = TRUE;
}
@@ -4908,7 +4922,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
if (indx != -1)
irel->r_symndx = indx;
- else
+ else if ((o->flags & SEC_DEBUGGING) == 0)
{
struct internal_syment *is;
@@ -4921,19 +4935,16 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
this case, but I don't think it's worth it. */
is = flinfo->internal_syms + r_symndx;
- if (is->n_sclass != C_DWARF)
- {
- name = (_bfd_coff_internal_syment_name
- (input_bfd, is, buf));
+ name = (_bfd_coff_internal_syment_name
+ (input_bfd, is, buf));
- if (name == NULL)
- return FALSE;
+ if (name == NULL)
+ return FALSE;
- if (!(*flinfo->info->callbacks->unattached_reloc)
- (flinfo->info, name, input_bfd, o,
- irel->r_vaddr))
- return FALSE;
- }
+ if (!(*flinfo->info->callbacks->unattached_reloc)
+ (flinfo->info, name, input_bfd, o,
+ irel->r_vaddr))
+ return FALSE;
}
}
}
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 0929e52..19572d8 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -3979,7 +3979,34 @@ ppc_named_section (int ignore ATTRIBUTE_UNUSED)
real_name = ".data[RW]";
else
{
- as_bad (_("the XCOFF file format does not support arbitrary sections"));
+ /* Entries in this array correspond to the ones in
+ xcoff_dwsect_names. */
+ static const char * const dwarf_sections[XCOFF_DWSECT_NBR_NAMES] = {
+ ".debug_info",
+ ".debug_line",
+ ".debug_pubnames",
+ ".debug_pubtypes",
+ ".debug_aranges",
+ ".debug_abbrev",
+ ".debug_str",
+ ".debug_ranges",
+ ".debug_frame",
+ ".debug_loc",
+ ".debug_macinfo",
+ ".debug_macro", };
+ int i;
+
+ /* Try dwarf sections. */
+ for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
+ if (strcmp (user_name, dwarf_sections[i]) == 0)
+ {
+ *input_line_pointer = c;
+ demand_empty_rest_of_line ();
+ ppc_change_debug_section (i, 0);
+ return;
+ }
+
+ as_bad (_("The XCOFF file format does not support arbitrary sections"));
*input_line_pointer = c;
ignore_rest_of_line ();
return;
--
1.7.0.4
>From 9844e6383c141be6223889cad64fd8655e34505d Mon Sep 17 00:00:00 2001
From: Tristan Gingold <gingold@adacore.com>
Date: Wed, 21 Nov 2012 13:39:39 +0100
Subject: [PATCH 2/5] Add minimal support for tls section on AIX 7.1
include/coff/ChangeLog:
* internal.h (C_STTLS, C_GTLS): Define.
* xcoff.h (XMC_TL, XMC_TU, XMC_TE): Define.
bfd/ChangeLog:
* coff-rs6000.c (xcoff_create_csect_from_smclas): Handle more
smclas.
---
bfd/coff-rs6000.c | 10 +++++-----
include/coff/internal.h | 2 ++
include/coff/xcoff.h | 4 ++++
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 9388ce3..43171ef 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -3537,14 +3537,14 @@ xcoff_create_csect_from_smclas (bfd *abfd,
/* .sv64 = x_smclas == 17
This is an invalid csect for 32 bit apps. */
- static const char *names[19] =
+ static const char * const names[23] =
{
- ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
- ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0",
- ".td", NULL, ".sv3264"
+ ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", /* 0 - 7 */
+ ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0", /* 8 - 15 */
+ ".td", NULL, ".sv3264", NULL, ".tl", ".ul", ".te"
};
- if ((19 >= aux->x_csect.x_smclas)
+ if ((aux->x_csect.x_smclas < sizeof (names) / sizeof (*names))
&& (NULL != names[aux->x_csect.x_smclas]))
{
return_value = bfd_make_section_anyway
diff --git a/include/coff/internal.h b/include/coff/internal.h
index f52bfbb..8b84324 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -343,6 +343,8 @@ struct internal_aouthdr
#define C_FUN (0x8e)
#define C_BSTAT (0x8f)
#define C_ESTAT (0x90)
+#define C_GTLS (0x97)
+#define C_STTLS (0x98)
/* Storage classes for Thumb symbols */
#define C_THUMBEXT (128 + C_EXT) /* 130 */
diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h
index 31b5071..6e290ad 100644
--- a/include/coff/xcoff.h
+++ b/include/coff/xcoff.h
@@ -171,6 +171,10 @@
#define XMC_TD 16 /* Read-write data in TOC */
#define XMC_SV64 17 /* Read-only 64 bit supervisor call */
#define XMC_SV3264 18 /* Read-only 32 or 64 bit supervisor call */
+/* 19 ??? */
+#define XMC_TL 20 /* Read-write initialized TLS data */
+#define XMC_TU 21 /* Read-write uninitialized TLS data */
+#define XMC_TE 22 /* Same as XMC_TE but mapped after it */
/* The ldhdr structure. This appears at the start of the .loader
section. */
--
1.7.0.4
>From 4eefb504fd70c779518d9ff6b0798b27f669d34d Mon Sep 17 00:00:00 2001
From: Tristan Gingold <gingold@adacore.com>
Date: Thu, 22 Nov 2012 10:30:54 +0100
Subject: [PATCH 3/5] AIX: .data and .text alignment issue on AIX 7.1
Without this change, we can get the error when trying to run
a program on AIX 7.1:
exec(): 0509-036 Cannot load program ./toto because of the following errors:
0509-118 The alignment of the .text section does not
satisfy its required alignment.
0509-194 Examine file headers with the 'dump -ohv' command.
We made it simple, and increased the alignment requirements on all
AIX versions, rather than just AIX 7 and newer.
ld/ChangeLog:
* emultempl/aix.em (_handle_option): Take .data and .text
alignment to compute start address.
* scripttempl/aix.sc: Likewise.
---
ld/emultempl/aix.em | 20 ++++++++++++++------
ld/scripttempl/aix.sc | 8 ++++++--
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em
index b48228a..35f14b8 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -572,15 +572,19 @@ gld${EMULATION_NAME}_handle_option (int optc)
else
{
etree_type *t;
+ etree_type *m;
+ /* .data = ALIGN (val + (. & 0xfff),
+ MAX (64, ALIGNOF (.data))); */
t = exp_binop ('+',
exp_intop (val),
exp_binop ('&',
exp_nameop (NAME, "."),
exp_intop (0xfff)));
- t = exp_binop ('&',
- exp_binop ('+', t, exp_intop (31)),
- exp_intop (~(bfd_vma) 31));
+ m = exp_binop (MAX_K,
+ exp_intop (64),
+ exp_nameop (ALIGNOF, ".data"));
+ t = exp_binop (ALIGN_K, t, m);
lang_section_start (".data", t, NULL);
}
break;
@@ -595,13 +599,17 @@ gld${EMULATION_NAME}_handle_option (int optc)
else
{
etree_type *t;
+ etree_type *m;
+ /* .text = ALIGN (val + SIZEOF_HEADERS,
+ MAX (64, ALIGNOF (.text))); */
t = exp_binop ('+',
exp_intop (val),
exp_nameop (SIZEOF_HEADERS, NULL));
- t = exp_binop ('&',
- exp_binop ('+', t, exp_intop (31)),
- exp_intop (~(bfd_vma) 31));
+ m = exp_binop (MAX_K,
+ exp_intop (64),
+ exp_nameop (ALIGNOF, ".text"));
+ t = exp_binop (ALIGN_K, t, m);
lang_section_start (".text", t, NULL);
}
break;
diff --git a/ld/scripttempl/aix.sc b/ld/scripttempl/aix.sc
index adc5de6..6bb777a 100644
--- a/ld/scripttempl/aix.sc
+++ b/ld/scripttempl/aix.sc
@@ -11,7 +11,9 @@ SECTIONS
{
.pad 0 : { *(.pad) }
- . = ALIGN (0x10000000 + SIZEOF_HEADERS, 32);
+ /* Note that this command can be overriden by option -bpT: */
+ . = ALIGN (0x10000000 + SIZEOF_HEADERS, MAX (ALIGNOF (.text), 64));
+
.text ${RELOCATING-0} : {
${RELOCATING+PROVIDE (_text = .);}
*(.text)
@@ -25,7 +27,9 @@ SECTIONS
${RELOCATING+PROVIDE (_etext = .);}
}
- . = ALIGN (ALIGN (0x10000000) + (. & 0xfff), 32);
+ /* Note that this command can be overriden by option -bpD: */
+ . = ALIGN (ALIGN (0x10000000) + (. & 0xfff), MAX (ALIGNOF (.data), 64));
+
.data . : {
${RELOCATING+PROVIDE (_data = .);}
*(.data)
--
1.7.0.4
>From 353cdb30c1b849707185ee80e0fe9b0585846adb Mon Sep 17 00:00:00 2001
From: Tristan Gingold <gingold@chinon.act-europe.fr>
Date: Tue, 11 Oct 2011 13:47:30 +0200
Subject: [PATCH 4/5] aix: dump core files.
include/coff/ChangeLog:
* include/coff/rs6000.h (struct external_core_dumpx): New.
(CORE_DUMPX_VERSION, CORE_DUMPXX_VERSION): Define.
(struct external_ld_info32): New.
binutils/ChangeLog:
* od-xcoff.c (OPT_LDINFO): Define.
(options): Add entry for "ldinfo" option.
(xcoff_help): Add help for "ldinfo" option.
(xcoff_dump_obj): Renames xcoff_dump. Add break statement
at end of default case.
(dump_dumpx_core, xcoff_dump_core, xcoff_dump): New functions.
---
binutils/od-xcoff.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++-
include/coff/rs6000.h | 60 +++++++++++++++++
2 files changed, 226 insertions(+), 2 deletions(-)
diff --git a/binutils/od-xcoff.c b/binutils/od-xcoff.c
index d7056a8..e2356ec 100644
--- a/binutils/od-xcoff.c
+++ b/binutils/od-xcoff.c
@@ -49,6 +49,7 @@
#define OPT_TYPCHK 8
#define OPT_TRACEBACK 9
#define OPT_TOC 10
+#define OPT_LDINFO 11
/* List of actions. */
static struct objdump_private_option options[] =
@@ -64,6 +65,7 @@ static struct objdump_private_option options[] =
{ "typchk", 0 },
{ "traceback", 0 },
{ "toc", 0 },
+ { "ldinfo", 0 },
{ NULL, 0 }
};
@@ -85,6 +87,7 @@ For XCOFF files:\n\
typchk Display type-check section\n\
traceback Display traceback tags\n\
toc Display toc symbols\n\
+ ldinfo Display loader info in core files\n\
"));
}
@@ -1628,7 +1631,7 @@ dump_xcoff32 (bfd *abfd, struct external_filehdr *fhdr)
/* Dump ABFD (according to the options[] array). */
static void
-xcoff_dump (bfd *abfd)
+xcoff_dump_obj (bfd *abfd)
{
struct external_filehdr fhdr;
unsigned short magic;
@@ -1659,7 +1662,8 @@ xcoff_dump (bfd *abfd)
printf (_("(TOCMAGIC: readonly text segments and TOC)"));
break;
default:
- printf (_("unknown magic"));
+ printf (_("unknown magic"));
+ break;
}
putchar ('\n');
}
@@ -1669,6 +1673,166 @@ xcoff_dump (bfd *abfd)
printf (_(" Unhandled magic\n"));
}
+/* Handle an AIX dumpx core file. */
+
+static void
+dump_dumpx_core (bfd *abfd, struct external_core_dumpx *hdr)
+{
+ if (options[OPT_FILE_HEADER].selected)
+ {
+ printf (" signal: %u\n", bfd_h_get_8 (abfd, hdr->c_signo));
+ printf (" flags: 0x%02x\n", bfd_h_get_8 (abfd, hdr->c_flag));
+ printf (" entries: %u\n",
+ (unsigned) bfd_h_get_16 (abfd, hdr->c_entries));
+#ifdef BFD64
+ printf (" fdsinfox: offset: 0x%08" BFD_VMA_FMT "x\n",
+ bfd_h_get_64 (abfd, hdr->c_fdsinfox));
+ printf (" loader: offset: 0x%08" BFD_VMA_FMT "x, "
+ "size: 0x%" BFD_VMA_FMT"x\n",
+ bfd_h_get_64 (abfd, hdr->c_loader),
+ bfd_h_get_64 (abfd, hdr->c_lsize));
+ printf (" thr: offset: 0x%08" BFD_VMA_FMT "x, nbr: %u\n",
+ bfd_h_get_64 (abfd, hdr->c_thr),
+ (unsigned) bfd_h_get_32 (abfd, hdr->c_n_thr));
+ printf (" segregions: offset: 0x%08" BFD_VMA_FMT "x, "
+ "nbr: %" BFD_VMA_FMT "u\n",
+ bfd_h_get_64 (abfd, hdr->c_segregion),
+ bfd_h_get_64 (abfd, hdr->c_segs));
+ printf (" stack: offset: 0x%08" BFD_VMA_FMT "x, "
+ "org: 0x%" BFD_VMA_FMT"x, "
+ "size: 0x%" BFD_VMA_FMT"x\n",
+ bfd_h_get_64 (abfd, hdr->c_stack),
+ bfd_h_get_64 (abfd, hdr->c_stackorg),
+ bfd_h_get_64 (abfd, hdr->c_size));
+ printf (" data: offset: 0x%08" BFD_VMA_FMT "x, "
+ "org: 0x%" BFD_VMA_FMT"x, "
+ "size: 0x%" BFD_VMA_FMT"x\n",
+ bfd_h_get_64 (abfd, hdr->c_data),
+ bfd_h_get_64 (abfd, hdr->c_dataorg),
+ bfd_h_get_64 (abfd, hdr->c_datasize));
+ printf (" sdata: org: 0x%" BFD_VMA_FMT"x, "
+ "size: 0x%" BFD_VMA_FMT"x\n",
+ bfd_h_get_64 (abfd, hdr->c_sdorg),
+ bfd_h_get_64 (abfd, hdr->c_sdsize));
+ printf (" vmmregions: offset: 0x%" BFD_VMA_FMT"x, "
+ "num: 0x%" BFD_VMA_FMT"x\n",
+ bfd_h_get_64 (abfd, hdr->c_vmm),
+ bfd_h_get_64 (abfd, hdr->c_vmmregions));
+ printf (" impl: 0x%08x\n",
+ (unsigned) bfd_h_get_32 (abfd, hdr->c_impl));
+ printf (" cprs: 0x%" BFD_VMA_FMT "x\n",
+ bfd_h_get_64 (abfd, hdr->c_cprs));
+#endif
+ }
+ if (options[OPT_LDINFO].selected)
+ {
+#ifdef BFD64
+ file_ptr off = (file_ptr) bfd_h_get_64 (abfd, hdr->c_loader);
+ bfd_size_type len = (bfd_size_type) bfd_h_get_64 (abfd, hdr->c_lsize);
+ char *ldr;
+
+ ldr = xmalloc (len);
+ if (bfd_seek (abfd, off, SEEK_SET) != 0
+ || bfd_bread (ldr, len, abfd) != len)
+ {
+ non_fatal (_("cannot read loader info table"));
+ }
+ else
+ {
+ char *p;
+
+ printf ("\n"
+ "ld info:\n");
+ printf (" next core off textorg textsize dataorg datasize\n");
+ p = ldr;
+ while (1)
+ {
+ struct external_ld_info32 *l = (struct external_ld_info32 *)p;
+ unsigned int next;
+ size_t n1;
+
+ next = bfd_h_get_32 (abfd, l->ldinfo_next);
+ printf (" %08x %08x %08x %08x %08x %08x\n",
+ next,
+ (unsigned) bfd_h_get_32 (abfd, l->core_offset),
+ (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textorg),
+ (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textsize),
+ (unsigned) bfd_h_get_32 (abfd, l->ldinfo_dataorg),
+ (unsigned) bfd_h_get_32 (abfd, l->ldinfo_datasize));
+ n1 = strlen ((char *) l->ldinfo_filename);
+ printf (" %s %s\n",
+ l->ldinfo_filename, l->ldinfo_filename + n1 + 1);
+ if (next == 0)
+ break;
+ p += next;
+ }
+ }
+#else
+ printf (_("\n"
+ "ld info dump not supported in 32 bits environments\n"));
+#endif
+ }
+}
+
+/* Dump a core file. */
+
+static void
+xcoff_dump_core (bfd *abfd)
+{
+ struct external_core_dumpx hdr;
+ unsigned int version;
+
+ /* Read file header. */
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0
+ || bfd_bread (&hdr, sizeof (hdr), abfd) != sizeof (hdr))
+ {
+ non_fatal (_("cannot core read header"));
+ return;
+ }
+
+ version = bfd_h_get_32 (abfd, hdr.c_version);
+ if (options[OPT_FILE_HEADER].selected)
+ {
+ printf (_("Core header:\n"));
+ printf (_(" version: 0x%08x "), version);
+ switch (version)
+ {
+ case CORE_DUMPX_VERSION:
+ printf (_("(dumpx format - aix4.3 / 32 bits)"));
+ break;
+ case CORE_DUMPXX_VERSION:
+ printf (_("(dumpxx format - aix5.0 / 64 bits)"));
+ break;
+ default:
+ printf (_("unknown format"));
+ break;
+ }
+ putchar ('\n');
+ }
+ if (version == CORE_DUMPX_VERSION)
+ dump_dumpx_core (abfd, &hdr);
+ else
+ printf (_(" Unhandled magic\n"));
+}
+
+/* Dump an XCOFF file. */
+
+static void
+xcoff_dump (bfd *abfd)
+{
+ /* We rely on BFD to decide if the file is a core file. Note that core
+ files are only supported on native environment by BFD. */
+ switch (bfd_get_format (abfd))
+ {
+ case bfd_core:
+ xcoff_dump_core (abfd);
+ break;
+ default:
+ xcoff_dump_obj (abfd);
+ break;
+ }
+}
+
/* Vector for xcoff. */
const struct objdump_private_desc objdump_private_desc_xcoff =
diff --git a/include/coff/rs6000.h b/include/coff/rs6000.h
index d5b2af2..3a89178 100644
--- a/include/coff/rs6000.h
+++ b/include/coff/rs6000.h
@@ -291,3 +291,63 @@ struct external_exceptab
};
#define EXCEPTSZ (4 + 2)
+
+/******************** Core files *************************/
+
+struct external_core_dumpx
+{
+ unsigned char c_signo[1];
+ unsigned char c_flag[1];
+ unsigned char c_entries[2];
+
+ unsigned char c_version[4];
+
+ unsigned char c_fdsinfox[8];
+ unsigned char c_loader[8];
+ unsigned char c_lsize[8];
+
+ unsigned char c_n_thr[4];
+ unsigned char c_reserved0[4];
+ unsigned char c_thr[8];
+
+ unsigned char c_segs[8];
+ unsigned char c_segregion[8];
+
+ unsigned char c_stack[8];
+ unsigned char c_stackorg[8];
+ unsigned char c_size[8];
+
+ unsigned char c_data[8];
+ unsigned char c_dataorg[8];
+ unsigned char c_datasize[8];
+ unsigned char c_sdorg[8];
+ unsigned char c_sdsize[8];
+
+ unsigned char c_vmmregions[8];
+ unsigned char c_vmm[8];
+
+ unsigned char c_impl[4];
+ unsigned char c_pad[4];
+ unsigned char c_cprs[8];
+ unsigned char c_reserved[7 * 8];
+
+ /* Followed by:
+ - context of the faulting thread.
+ - user structure. */
+};
+
+
+/* Core file verion. */
+#define CORE_DUMPX_VERSION 0x0feeddb1
+#define CORE_DUMPXX_VERSION 0x0feeddb2
+
+struct external_ld_info32
+{
+ unsigned char ldinfo_next[4];
+ unsigned char core_offset[4];
+ unsigned char ldinfo_textorg[4];
+ unsigned char ldinfo_textsize[4];
+ unsigned char ldinfo_dataorg[4];
+ unsigned char ldinfo_datasize[4];
+ unsigned char ldinfo_filename[2];
+};
--
1.7.0.4
>From 182933aa599bedfd9411ba915826515777026148 Mon Sep 17 00:00:00 2001
From: Tristan Gingold <gingold@adacore.com>
Date: Thu, 29 Nov 2012 16:57:17 +0100
Subject: [PATCH 5/5] Fix addr2line for xcoff.
bfd/ChangeLog:
* coff-rs6000.c (xcoff_find_nearest_line_discriminator): New function.
(rs6000coff_vec): Reference it.
---
bfd/coff-rs6000.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 43171ef..1460e31 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -449,6 +449,23 @@ xcoff_find_nearest_line (bfd *abfd,
line_ptr);
}
+static bfd_boolean
+xcoff_find_nearest_line_discriminator (bfd *abfd,
+ asection *section,
+ asymbol **symbols,
+ bfd_vma offset,
+ const char **filename_ptr,
+ const char **functionname_ptr,
+ unsigned int *line_ptr,
+ unsigned int *discriminator)
+{
+ *discriminator = 0;
+ return coff_find_nearest_line_with_names (abfd, xcoff_debug_sections,
+ section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr);
+}
+
void
_bfd_xcoff_swap_sym_in (bfd *abfd, void * ext1, void * in1)
@@ -4122,7 +4139,7 @@ const bfd_target rs6000coff_vec =
coff_bfd_is_target_special_symbol,
coff_get_lineno,
xcoff_find_nearest_line,
- _bfd_generic_find_nearest_line_discriminator,
+ xcoff_find_nearest_line_discriminator,
_bfd_generic_find_line,
coff_find_inliner_info,
coff_bfd_make_debug_symbol,
--
1.7.0.4