From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: arnej@pvv.unit.no Cc: gas2@cygnus.com Subject: Re: .gas.warning sections Date: Mon, 04 Dec 1995 08:25:00 -0000 Message-id: <199512041625.LAA20339@sanguine.cygnus.com> References: <9512022057.AA11248@datter.pvv.unit.no> X-SW-Source: 1995/msg00210.html From: "Arne H. Juul" Date: Sat, 2 Dec 1995 21:57:49 +0100 #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ do { \ extern FILE *asm_out_text_file; \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ else if ((DECL) && TREE_READONLY (DECL)) \ fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ else \ fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ } while (0) This is probably really an assembler question: Is all this stuff really necessary, and what does the extra @progbits mean? Yes, all that stuff is really necessary. I'm not sure why you say the @progbits is extra. It means that the section contains data that forms part of the program image; by way of comparison, a DWARF debugging section contains data, but it is not part of the program image. This ASM_OUTPUT_SECTION_NAME macro is very similar to the one in config/svr4.h, except that it uses asm_out_text_file instead of F when selecting the section for a function declaration. This is required for the way the MIPS backend handles global pointer optimizations. Stuffing this code into netbsd.h as well seemed to work ok, but then I looked a bit further, and while svr4.h has a somewhat simple version of this, h8300/h8300.h has something more like what I had imagined: #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ fprintf (FILE, "\t.section %s\n", NAME) It's definitely best to tell the assembler the flags and type to give the section. It never hurts, and sometimes it is required. You also need to keep the asm_out_text_file distinction in order for functions to be put in the right place. However, if I change my test file to have *only* the warning section for null1 (not the function definition itself), I get the following behaviour: gcc: Internal compiler error: program ld got fatal signal 6 This is a linker bug. Here's the patch. Ian Index: elflink.h =================================================================== RCS file: /cvs/cvsfiles/devo/bfd/elflink.h,v retrieving revision 1.21 diff -u -r1.21 elflink.h --- elflink.h 1995/12/01 19:47:51 1.21 +++ elflink.h 1995/12/04 16:14:12 @@ -2508,6 +2508,12 @@ case bfd_link_hash_indirect: case bfd_link_hash_warning: + /* We can't represent these symbols in ELF. A warning symbol + may have come from a .gnu.warning.SYMBOL section anyhow. We + just put the target symbol in the hash table. If the target + symbol does not really exist, don't do anything. */ + if (h->root.u.i.link->type == bfd_link_hash_new) + return true; return (elf_link_output_extsym ((struct elf_link_hash_entry *) h->root.u.i.link, data)); }