aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorCl?ment Chigot <clement.chigot@atos.net>2021-05-07 15:29:49 +0100
committerNick Clifton <nickc@redhat.com>2021-05-07 15:29:49 +0100
commit97834047e13bb9f30430331c27b11412a5ed6950 (patch)
tree99f794403e03440f9ed501fed952517bf98a4e9e /gas
parent3ecc00ec9cbb7a35d6e58bf86fddaa33126a479a (diff)
downloadgdb-97834047e13bb9f30430331c27b11412a5ed6950.zip
gdb-97834047e13bb9f30430331c27b11412a5ed6950.tar.gz
gdb-97834047e13bb9f30430331c27b11412a5ed6950.tar.bz2
Fix .dwsect generation for XCOFF. Handle .function generated with DWARF on XCOFF.
gas * config/tc-ppc.c (ppc_function): Update comment for fifth argument. (ppc_frob_symbol): Remove ppc_last_function check. Make sure coff_last_function is reset. Correctly set fsize when not provided in .function. * testsuite/gas/ppc/aix.exp: New tests. * testsuite/gas/ppc/xcoff-function-1-32.d: New test. * testsuite/gas/ppc/xcoff-function-1-64.d: New test. * testsuite/gas/ppc/xcoff-function-1.s: New test. bfd * coff-rs6000.c (xcoff_dwsect_names): Add new DWARF sections. * coffgen.c (coff_pointerize_aux): Handle C_DWARF. (coff_print_symbol): Likewise. * libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Update. gas * config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF. (coff_adjust_section_syms): Use corrext auxent for C_DWARF. (coff_frob_section): Likewise. * config/obj-coff.h (SA_GET_SECT_SCNLEN, SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN, SA_SET_SECT_NRELOC) New defines. (SET_SECTION_RELOCS): Adjust for C_DWARF. * config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF. (ppc_adjust_symtab): Reorder C_DWARF symbols. * testsuite/gas/ppc/aix.exp: New tests. * testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test. * testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test. * testsuite/gas/ppc/xcoff-dwsect-2.s: New test. include * coff/internal.h (C_DWARF): New define. * coff/xcoff.h (SSUBTYP_DWLOC, SSUBTYP_DWFRAME, SSUBTYP_DWMAC): New defines.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog26
-rw-r--r--gas/config/obj-coff.c15
-rw-r--r--gas/config/obj-coff.h18
-rw-r--r--gas/config/tc-ppc.c54
-rw-r--r--gas/testsuite/gas/ppc/aix.exp5
-rw-r--r--gas/testsuite/gas/ppc/xcoff-dwsect-2-32.d18
-rw-r--r--gas/testsuite/gas/ppc/xcoff-dwsect-2-64.d18
-rw-r--r--gas/testsuite/gas/ppc/xcoff-dwsect-2.s12
-rw-r--r--gas/testsuite/gas/ppc/xcoff-function-1-32.d20
-rw-r--r--gas/testsuite/gas/ppc/xcoff-function-1-64.d20
-rw-r--r--gas/testsuite/gas/ppc/xcoff-function-1.s16
11 files changed, 217 insertions, 5 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index b04a764..b5c358d 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,29 @@
+2021-05-07 Clément Chigot <clement.chigot@atos.net>
+
+ * config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF.
+ (coff_adjust_section_syms): Use corrext auxent for C_DWARF.
+ (coff_frob_section): Likewise.
+ * config/obj-coff.h (SA_GET_SECT_SCNLEN,
+ SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN,
+ SA_SET_SECT_NRELOC) New defines.
+ (SET_SECTION_RELOCS): Adjust for C_DWARF.
+ * config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF.
+ (ppc_adjust_symtab): Reorder C_DWARF symbols.
+ * testsuite/gas/ppc/aix.exp: New tests.
+ * testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test.
+ * testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test.
+ * testsuite/gas/ppc/xcoff-dwsect-2.s: New test.
+
+ * config/tc-ppc.c (ppc_function): Update comment for
+ fifth argument.
+ (ppc_frob_symbol): Remove ppc_last_function check.
+ Make sure coff_last_function is reset.
+ Correctly set fsize when not provided in .function.
+ * testsuite/gas/ppc/aix.exp: New tests.
+ * testsuite/gas/ppc/xcoff-function-1-32.d: New test.
+ * testsuite/gas/ppc/xcoff-function-1-64.d: New test.
+ * testsuite/gas/ppc/xcoff-function-1.s: New test.
+
2021-05-07 Jan Beulich <jbeulich@suse.com>
* testsuite/gas/i386/rela.s, testsuite/gas/i386/rela.d: New.
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index f3cc327..f2703ff 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -1379,6 +1379,7 @@ coff_frob_symbol (symbolS *symp, int *punt)
/* This is pretty horrible, but we have to set *punt correctly in
order to call SA_SET_SYM_ENDNDX correctly. */
if (! symbol_used_in_reloc_p (symp)
+ && S_GET_STORAGE_CLASS (symp) != C_DWARF
&& ((symbol_get_bfdsym (symp)->flags & BSF_SECTION_SYM) != 0
|| (! (S_IS_EXTERNAL (symp) || S_IS_WEAK (symp))
&& ! symbol_get_tc (symp)->output
@@ -1483,8 +1484,18 @@ coff_adjust_section_syms (bfd *abfd ATTRIBUTE_UNUSED,
secsym = section_symbol (sec);
/* This is an estimate; we'll plug in the real value using
SET_SECTION_RELOCS later */
+#ifdef OBJ_XCOFF
+ if (S_GET_STORAGE_CLASS (secsym) == C_DWARF)
+ SA_SET_SECT_NRELOC (secsym, nrelocs);
+ else
+ {
+ SA_SET_SCN_NRELOC (secsym, nrelocs);
+ SA_SET_SCN_NLINNO (secsym, nlnno);
+ }
+#else
SA_SET_SCN_NRELOC (secsym, nrelocs);
SA_SET_SCN_NLINNO (secsym, nlnno);
+#endif
}
void
@@ -1754,7 +1765,11 @@ coff_frob_section (segT sec)
S_SET_STORAGE_CLASS (secsym, sclass);
S_SET_NUMBER_AUXILIARY (secsym, 1);
SF_SET_STATICS (secsym);
+#ifdef OBJ_XCOFF
+ SA_SET_SECT_SCNLEN (secsym, size);
+#else
SA_SET_SCN_SCNLEN (secsym, size);
+#endif
}
/* FIXME: These should be in a "stabs.h" file, or maybe as.h. */
#ifndef STAB_SECTION_NAME
diff --git a/gas/config/obj-coff.h b/gas/config/obj-coff.h
index 917b659..73c001e 100644
--- a/gas/config/obj-coff.h
+++ b/gas/config/obj-coff.h
@@ -180,6 +180,13 @@
#define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc = (v))
#define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno = (v))
+#ifdef OBJ_XCOFF
+#define SA_GET_SECT_SCNLEN(s) (SYM_AUXENT (s)->x_sect.x_scnlen)
+#define SA_GET_SECT_NRELOC(s) (SYM_AUXENT (s)->x_sect.x_nreloc)
+#define SA_SET_SECT_SCNLEN(s,v) (SYM_AUXENT (s)->x_sect.x_scnlen = (v))
+#define SA_SET_SECT_NRELOC(s,v) (SYM_AUXENT (s)->x_sect.x_nreloc = (v))
+#endif
+
/* Internal use only definitions. SF_ stands for symbol flags.
These values can be assigned to sy_symbol.ost_flags field of a symbolS. */
@@ -294,8 +301,19 @@ extern const pseudo_typeS coff_pseudo_table[];
#define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg)
/* Store the number of relocations in the section aux entry. */
+#ifdef OBJ_XCOFF
+#define SET_SECTION_RELOCS(sec, relocs, n) \
+ do { \
+ symbolS * sectSym = section_symbol (sec); \
+ if (S_GET_STORAGE_CLASS (sectSym) == C_DWARF) \
+ SA_SET_SECT_NRELOC (sectSym, n); \
+ else \
+ SA_SET_SCN_NRELOC (sectSym, n); \
+ } while (0)
+#else
#define SET_SECTION_RELOCS(sec, relocs, n) \
SA_SET_SCN_NRELOC (section_symbol (sec), n)
+#endif
#define obj_app_file(name, app) c_dot_file_symbol (name, app)
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 7715fc5..fce2b15 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -5144,7 +5144,9 @@ ppc_function (int ignore ATTRIBUTE_UNUSED)
expression (& exp);
if (*input_line_pointer == ',')
{
- /* The fifth argument is the function size. */
+ /* The fifth argument is the function size.
+ If it's omitted, the size will be the containing csect.
+ This will be donce during ppc_frob_symtab. */
++input_line_pointer;
symbol_get_tc (ext_sym)->u.size
= symbol_new ("L0\001", absolute_section,
@@ -5864,6 +5866,7 @@ ppc_frob_symbol (symbolS *sym)
/* Discard symbols that should not be included in the output symbol
table. */
if (! symbol_used_in_reloc_p (sym)
+ && S_GET_STORAGE_CLASS (sym) != C_DWARF
&& ((symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) != 0
|| (! (S_IS_EXTERNAL (sym) || S_IS_WEAK (sym))
&& ! symbol_get_tc (sym)->output
@@ -5903,8 +5906,9 @@ ppc_frob_symbol (symbolS *sym)
if (SF_GET_FUNCTION (sym))
{
- if (ppc_last_function != (symbolS *) NULL)
- as_bad (_("two .function pseudo-ops with no intervening .ef"));
+ /* Make sure coff_last_function is reset. Otherwise, we won't create
+ the auxent for the next function. */
+ coff_last_function = 0;
ppc_last_function = sym;
if (symbol_get_tc (sym)->u.size != (symbolS *) NULL)
{
@@ -5912,6 +5916,16 @@ ppc_frob_symbol (symbolS *sym)
SA_SET_SYM_FSIZE (sym,
(long) S_GET_VALUE (symbol_get_tc (sym)->u.size));
}
+ else
+ {
+ /* Size of containing csect. */
+ symbolS* within = symbol_get_tc (sym)->within;
+ union internal_auxent *csectaux;
+ csectaux = &coffsymbol (symbol_get_bfdsym (within))
+ ->native[S_GET_NUMBER_AUXILIARY(within)].u.auxent;
+
+ SA_SET_SYM_FSIZE (sym, csectaux->x_csect.x_scnlen.l);
+ }
}
else if (S_GET_STORAGE_CLASS (sym) == C_FCN
&& strcmp (S_GET_NAME (sym), ".ef") == 0)
@@ -6126,13 +6140,43 @@ ppc_frob_symbol (symbolS *sym)
return 0;
}
-/* Adjust the symbol table. This creates csect symbols for all
- absolute symbols. */
+/* Adjust the symbol table. */
void
ppc_adjust_symtab (void)
{
symbolS *sym;
+ symbolS *anchorSym;
+
+ /* Make sure C_DWARF symbols come right after C_FILE.
+ As the C_FILE might not be defined yet and as C_DWARF
+ might already be ordered, we insert them before the
+ first symbol which isn't a C_FILE or a C_DWARF. */
+ for (anchorSym = symbol_rootP; anchorSym != NULL;
+ anchorSym = symbol_next (anchorSym))
+ {
+ if (S_GET_STORAGE_CLASS (anchorSym) != C_FILE
+ && S_GET_STORAGE_CLASS (anchorSym) != C_DWARF)
+ break;
+ }
+
+ sym = anchorSym;
+ while (sym != NULL)
+ {
+ if (S_GET_STORAGE_CLASS (sym) != C_DWARF)
+ {
+ sym = symbol_next (sym);
+ continue;
+ }
+
+ symbolS* tsym = sym;
+ sym = symbol_next (sym);
+
+ symbol_remove (tsym, &symbol_rootP, &symbol_lastP);
+ symbol_insert (tsym, anchorSym, &symbol_rootP, &symbol_lastP);
+ }
+
+ /* Create csect symbols for all absolute symbols. */
if (! ppc_saw_abs)
return;
diff --git a/gas/testsuite/gas/ppc/aix.exp b/gas/testsuite/gas/ppc/aix.exp
index 8e7ac67..efe27e4 100644
--- a/gas/testsuite/gas/ppc/aix.exp
+++ b/gas/testsuite/gas/ppc/aix.exp
@@ -73,4 +73,9 @@ if { [istarget "powerpc*-*-aix*"] || [istarget "rs6000-*-aix*"] } then {
run_dump_test "xcoff-dwsect-1-32"
run_dump_test "xcoff-dwsect-1-64"
+ run_dump_test "xcoff-dwsect-2-32"
+ run_dump_test "xcoff-dwsect-2-64"
+
+ run_dump_test "xcoff-function-1-32"
+ run_dump_test "xcoff-function-1-64"
}
diff --git a/gas/testsuite/gas/ppc/xcoff-dwsect-2-32.d b/gas/testsuite/gas/ppc/xcoff-dwsect-2-32.d
new file mode 100644
index 0000000..cebc6d3
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-dwsect-2-32.d
@@ -0,0 +1,18 @@
+#as: -a32
+#source: xcoff-dwsect-2.s
+#objdump: -t
+#name: XCOFF dwsect test 2 (32-bit)
+
+.*
+
+SYMBOL TABLE:
+.*\(scl 103\).*
+File .*
+.*\(scl 112\).* .dwinfo
+AUX .*
+.*\(scl 112\).* .dwloc
+AUX .*
+.*\(scl 112\).* .dwarnge
+AUX .*
+.*\(scl 107\).* .text
+.*
diff --git a/gas/testsuite/gas/ppc/xcoff-dwsect-2-64.d b/gas/testsuite/gas/ppc/xcoff-dwsect-2-64.d
new file mode 100644
index 0000000..445e707
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-dwsect-2-64.d
@@ -0,0 +1,18 @@
+#as: -a64
+#source: xcoff-dwsect-2.s
+#objdump: -t
+#name: XCOFF dwsect test 2 (64-bit)
+
+.*
+
+SYMBOL TABLE:
+.*\(scl 103\).*
+File .*
+.*\(scl 112\).* .dwinfo
+AUX .*
+.*\(scl 112\).* .dwloc
+AUX .*
+.*\(scl 112\).* .dwarnge
+AUX .*
+.*\(scl 107\).* .text
+.*
diff --git a/gas/testsuite/gas/ppc/xcoff-dwsect-2.s b/gas/testsuite/gas/ppc/xcoff-dwsect-2.s
new file mode 100644
index 0000000..52a624f
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-dwsect-2.s
@@ -0,0 +1,12 @@
+
+ .csect .text[PR]
+
+ .dwsect 0x10000,Ldwinfo_0
+ .short 2
+ .dwsect 0x90000
+Ldebug_loc:
+ .short 3
+ .dwsect 0x50000
+ .short 1
+ .short 4
+
diff --git a/gas/testsuite/gas/ppc/xcoff-function-1-32.d b/gas/testsuite/gas/ppc/xcoff-function-1-32.d
new file mode 100644
index 0000000..805a248
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-function-1-32.d
@@ -0,0 +1,20 @@
+#as: -a32
+#source: xcoff-function-1.s
+#objdump: -t
+#name: XCOFF function test 1 (32-bit)
+
+.*
+
+SYMBOL TABLE:
+.*
+.*
+\[ 2\].* .text
+AUX val 8 .*
+\[ 4\].* .foo
+AUX .* ttlsiz 0x8 .*
+AUX .* typ 2 .* clss 0 .*
+\[ 7\].* .bar
+AUX .* ttlsiz 0x4 .*
+AUX .* typ 2 .* clss 0 .*
+
+
diff --git a/gas/testsuite/gas/ppc/xcoff-function-1-64.d b/gas/testsuite/gas/ppc/xcoff-function-1-64.d
new file mode 100644
index 0000000..431c61c
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-function-1-64.d
@@ -0,0 +1,20 @@
+#as: -a64
+#source: xcoff-function-1.s
+#objdump: -t
+#name: XCOFF function test 1 (64-bit)
+
+.*
+
+SYMBOL TABLE:
+.*
+.*
+\[ 2\].* .text
+AUX val 8 .*
+\[ 4\].* .foo
+AUX .* ttlsiz 0x8 .*
+AUX .* typ 2 .* clss 0 .*
+\[ 7\].* .bar
+AUX .* ttlsiz 0x4 .*
+AUX .* typ 2 .* clss 0 .*
+
+
diff --git a/gas/testsuite/gas/ppc/xcoff-function-1.s b/gas/testsuite/gas/ppc/xcoff-function-1.s
new file mode 100644
index 0000000..8a63fe7
--- /dev/null
+++ b/gas/testsuite/gas/ppc/xcoff-function-1.s
@@ -0,0 +1,16 @@
+ .csect .text[PR]
+
+ # .function without 5th argument means
+ # that the size is the size of the csect.
+ .globl .foo
+.foo:
+ .function .foo,.foo,2,0
+ blr
+
+ # .function without 5th argument means
+ # that the size is the size given.
+ .globl .bar
+.bar:
+ .function .bar,.bar,2,0, E..bar-.bar
+ blr
+E..bar: