From e86fc4a5bc3747a6b811d93648a2afa4c1c74217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= Date: Fri, 15 Oct 2021 16:12:39 +0200 Subject: PR 28447: implement multiple parameters for .file on XCOFF On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide additional information to AIX linker, or its debugger. These are stored in auxiliary entries of the C_FILE symbol. bfd/ PR 28447 * coffcode.h (combined_entry_type): Add extrap field. (coff_bigobj_swap_aux_in): Adjust names of x_file fields. (coff_bigobj_swap_aux_out): Likewise. * coffgen.c (coff_write_auxent_fname): New function. (coff_fix_symbol_name): Write x_file using coff_write_auxent_fname. (coff_write_symbol): Likewise. (coff_write_symbols): Add C_FILE auxiliary entries to string table if needed. (coff_get_normalized_symtab): Adjust names of x_file fields. Normalize C_FILE auxiliary entries. (coff_print_symbol): Print C_FILE auxiliary entries. * coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust names of x_file fields. (_bfd_xcoff_swap_aux_out): Likewise. * coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise. (_bfd_xcoff64_swap_aux_out): Likewise. * cofflink.c (_bfd_coff_final_link): Likewise. (_bfd_coff_link_input_bfd): Likewise. * coffswap.h (coff_swap_aux_in): Likewise. * peXXigen.c (_bfd_XXi_swap_aux_in): Likewise. (_bfd_XXi_swap_aux_out): Likewise. * xcofflink.c (xcoff_link_input_bfd): Likewise. * libcoff.h: Regenerate. gas/ * config/tc-ppc.c (ppc_file): New function. * config/tc-ppc.h (OBJ_COFF_MAX_AUXENTRIES): Change to 4. * testsuite/gas/ppc/aix.exp: Add tests. * testsuite/gas/ppc/xcoff-file-32.d: New test. * testsuite/gas/ppc/xcoff-file-64.d: New test. * testsuite/gas/ppc/xcoff-file.s: New test. include/ * coff/internal.h (union internal_auxent): Change x_file to be a struct instead of a union. Add x_ftype field. * coff/rs6000.h (union external_auxent): Add x_resv field. * coff/xcoff.h (XFT_FN): New define. (XFT_CT): Likewise. (XFT_CV): Likewise. (XFT_CD): Likewise. --- gas/config/tc-ppc.c | 63 +++++++++++++++++++++++++++++++++++ gas/config/tc-ppc.h | 2 +- gas/testsuite/gas/ppc/aix.exp | 3 ++ gas/testsuite/gas/ppc/xcoff-file-32.d | 13 ++++++++ gas/testsuite/gas/ppc/xcoff-file-64.d | 13 ++++++++ gas/testsuite/gas/ppc/xcoff-file.s | 1 + 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/ppc/xcoff-file-32.d create mode 100644 gas/testsuite/gas/ppc/xcoff-file-64.d create mode 100644 gas/testsuite/gas/ppc/xcoff-file.s (limited to 'gas') diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index af025af..8750e37 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -107,6 +107,7 @@ static void ppc_es (int); static void ppc_csect (int); static void ppc_dwsect (int); static void ppc_change_csect (symbolS *, offsetT); +static void ppc_file (int); static void ppc_function (int); static void ppc_extern (int); static void ppc_lglobl (int); @@ -227,6 +228,7 @@ const pseudo_typeS md_pseudo_table[] = { "ei", ppc_biei, 1 }, { "es", ppc_es, 0 }, { "extern", ppc_extern, 0 }, + { "file", ppc_file, 0 }, { "function", ppc_function, 0 }, { "lglobl", ppc_lglobl, 0 }, { "ref", ppc_ref, 0 }, @@ -5073,6 +5075,67 @@ ppc_stabx (int ignore ATTRIBUTE_UNUSED) demand_empty_rest_of_line (); } +/* The .file pseudo-op. On XCOFF, .file can have several parameters + which are being added to the symbol table to provide additional + information. */ + +static void +ppc_file (int ignore ATTRIBUTE_UNUSED) +{ + char *sfname, *s1 = NULL, *s2 = NULL, *s3 = NULL; + int length, auxnb = 1; + + /* Some assemblers tolerate immediately following '"'. */ + if ((sfname = demand_copy_string (&length)) != 0) + { + coff_symbol_type *coffsym; + if (*input_line_pointer == ',') + { + ++input_line_pointer; + s1 = demand_copy_string (&length); + auxnb++; + + if (*input_line_pointer == ',') + { + ++input_line_pointer; + s2 = demand_copy_string (&length); + auxnb++; + + if (*input_line_pointer == ',') + { + ++input_line_pointer; + s3 = demand_copy_string (&length); + auxnb++; + } + } + } + + /* Use coff dot_file creation and adjust auxiliary entries. */ + c_dot_file_symbol (sfname, 0); + S_SET_NUMBER_AUXILIARY (symbol_rootP, auxnb); + coffsym = coffsymbol (symbol_get_bfdsym (symbol_rootP)); + coffsym->native[1].u.auxent.x_file.x_ftype = XFT_FN; + + if (s1) + { + coffsym->native[2].u.auxent.x_file.x_ftype = XFT_CT; + coffsym->native[2].extrap = s1; + } + if (s2) + { + coffsym->native[3].u.auxent.x_file.x_ftype = XFT_CV; + coffsym->native[3].extrap = s2; + } + if (s3) + { + coffsym->native[4].u.auxent.x_file.x_ftype = XFT_CD; + coffsym->native[4].extrap = s3; + } + + demand_empty_rest_of_line (); + } +} + /* The .function pseudo-op. This takes several arguments. The first argument seems to be the external name of the symbol. The second argument seems to be the label for the start of the function. gcc diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index fb18730..2d0a886 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -146,7 +146,7 @@ struct ppc_tc_sy #define TC_SYMFIELD_TYPE struct ppc_tc_sy /* We need an additional auxent for function symbols. */ -#define OBJ_COFF_MAX_AUXENTRIES 2 +#define OBJ_COFF_MAX_AUXENTRIES 4 /* Square and curly brackets are permitted in symbol names. */ #define LEX_BR 3 diff --git a/gas/testsuite/gas/ppc/aix.exp b/gas/testsuite/gas/ppc/aix.exp index aef295b..c6d10d5 100644 --- a/gas/testsuite/gas/ppc/aix.exp +++ b/gas/testsuite/gas/ppc/aix.exp @@ -84,4 +84,7 @@ if { [istarget "powerpc*-*-aix*"] || [istarget "rs6000-*-aix*"] } then { run_dump_test "xcoff-stsym-32" run_dump_test "xcoff-stsym-64" + + run_dump_test "xcoff-file-32" + run_dump_test "xcoff-file-64" } diff --git a/gas/testsuite/gas/ppc/xcoff-file-32.d b/gas/testsuite/gas/ppc/xcoff-file-32.d new file mode 100644 index 0000000..a831b3b --- /dev/null +++ b/gas/testsuite/gas/ppc/xcoff-file-32.d @@ -0,0 +1,13 @@ +#as: -a32 +#source: xcoff-file.s +#objdump: -t +#name: XCOFF file test (32-bit) + +.* + +SYMBOL TABLE: +\[ 0\].*\(scl 103\) \(nx 4\) .* file.s +File +File ftype 1 fname "A long string" +File ftype 2 fname "short" +File ftype 128 fname "Another long string inside the strign table." diff --git a/gas/testsuite/gas/ppc/xcoff-file-64.d b/gas/testsuite/gas/ppc/xcoff-file-64.d new file mode 100644 index 0000000..12bb6ef --- /dev/null +++ b/gas/testsuite/gas/ppc/xcoff-file-64.d @@ -0,0 +1,13 @@ +#as: -a64 +#source: xcoff-file.s +#objdump: -t +#name: XCOFF file test (64-bit) + +.* + +SYMBOL TABLE: +\[ 0\].*\(scl 103\) \(nx 4\) .* file.s +File +File ftype 1 fname "A long string" +File ftype 2 fname "short" +File ftype 128 fname "Another long string inside the strign table." diff --git a/gas/testsuite/gas/ppc/xcoff-file.s b/gas/testsuite/gas/ppc/xcoff-file.s new file mode 100644 index 0000000..229ab88 --- /dev/null +++ b/gas/testsuite/gas/ppc/xcoff-file.s @@ -0,0 +1 @@ +.file "file.s", "A long string", "short", "Another long string inside the strign table." -- cgit v1.1