Created attachment 27162 [details] Compressed rtld.i file (gdb) r Starting program: /home/dave/gnu/gcc/objdir/gcc/cc1 -fpreprocessed rtld.i -quiet -dumpbase rtld.i -auxbase rtld -O2 -Wall -Winline -Wwrite-strings -Wstrict-prototypes -std=gnu99 -version -fgnu89-inline -fmerge-all-constants -fno-stack-protector -fPIC -o xx.s GNU C (GCC) version 4.8.0 20120412 (experimental) [trunk revision 186378] (hppa-linux-gnu) compiled by GNU C version 4.8.0 20120412 (experimental) [trunk revision 186378], GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.8.0 20120412 (experimental) [trunk revision 186378] (hppa-linux-gnu) compiled by GNU C version 4.8.0 20120412 (experimental) [trunk revision 186378], GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: d431a91d532955514383649751f02954 rtld.c: In function ‘dl_main’: rtld.c:937:3: warning: implicit declaration of function ‘__canonicalize_funcptr_for_compare’ [-Wimplicit-function-declaration] Program received signal SIGSEGV, Segmentation fault. c_tree_printer (hash=false, set_locus=false, spec=0xa919b0 "D", text=0xfdf02608, pp=0xab7228, precision=<optimized out>, wide=<optimized out>) at ../../gcc/gcc/c-objc-common.c:116 116 if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t)) (gdb) bt #0 c_tree_printer (hash=false, set_locus=false, spec=0xa919b0 "D", text=0xfdf02608, pp=0xab7228, precision=<optimized out>, wide=<optimized out>) at ../../gcc/gcc/c-objc-common.c:116 #1 c_tree_printer (pp=0xab7228, text=0xfdf02608, spec=0xa919b0 "D", precision=0, wide=false, set_locus=false, hash=false) at ../../gcc/gcc/c-objc-common.c:89 #2 0x0089b42c in pp_base_format (pp=0xab7228, text=0xfdf02608) at ../../gcc/gcc/pretty-print.c:509 #3 0x00899730 in diagnostic_report_diagnostic (context=0xa917b4, diagnostic=0xfdf02708) at ../../gcc/gcc/diagnostic.c:644 #4 0x00899ba0 in error (gmsgid=<optimized out>) at ../../gcc/gcc/diagnostic.c:857 #5 0x0075b994 in get_section (name=0xa919b0 "D", flags=<optimized out>, decl=<optimized out>) at ../../gcc/gcc/varasm.c:318 #6 0x0076fbf4 in varpool_assemble_pending_decls () at ../../gcc/gcc/varpool.c:653 #7 varpool_assemble_pending_decls () at ../../gcc/gcc/varpool.c:638 #8 0x001e6464 in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:2637 #9 0x001e6b20 in cgraph_finalize_compilation_unit () at ../../gcc/gcc/cgraphunit.c:2720 #10 0x000be150 in c_write_global_declarations () at ../../gcc/gcc/c-decl.c:10053 #11 0x0050fdec in compile_file () at ../../gcc/gcc/toplev.c:572 (gdb) p t $1 = (tree) 0x0 4.6 successfully generates section conflict error message.
Created attachment 27219 [details] gcc48-pr52999.patch This patch avoids the ICE when diagnosing the section conflict, but not sure what to do to actually compile the testcase without errors. What ld.so does is not exactly kosher from GCC POV (it wants to put non-constant, writable variables into a section that GCC assumes is for constant variables that need relocations).
On 4/23/2012 5:58 AM, jakub at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52999 > > --- Comment #1 from Jakub Jelinek<jakub at gcc dot gnu.org> 2012-04-23 09:58:38 UTC --- > Created attachment 27219 [details] > --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27219 > gcc48-pr52999.patch > > This patch avoids the ICE when diagnosing the section conflict, but not sure > what to do to actually compile the testcase without errors. What ld.so does is > not exactly kosher from GCC POV (it wants to put non-constant, writable > variables into a section that GCC assumes is for constant variables that need > relocations). I asked a glibc maintainer whether it would be possible to work around the issue. I know from debugging that there is at least one varable in the code that's placed in .data.rel.ro and assigned to. So, the const qualifier can't be used for it. As things stand, glibc doesn't build with GCC 4.6 and later. One fix might be to provide an option to set the SECTION_OVERRIDE flag. Another might be to issue a warning rather than an error on section conflicts. Dave
Or for PA define __attribute_relro__ to nothing, or assume that users putting decls into .data.rel.ro or .data.rel.ro.local sections know what they are doing and just force SECTION_WRITE | SECTION_RELRO always for those.
On 4/23/2012 9:56 AM, jakub at gcc dot gnu.org wrote: > Or for PA define __attribute_relro__ to nothing, or assume that users putting > decls into .data.rel.ro or .data.rel.ro.local sections know what they are doing > and just force SECTION_WRITE | SECTION_RELRO always for those. hppa-linux uses the default section flags. Is there a reason why this is PA specific? I sense there must be as this would have come up before. It's -fPIC that triggers the error.
The PA specific thing there is that PA puts rtx constant pool into .data.rel.ro section, something that doesn't happen on i?86/x86_64/ppc/ppc64 etc. to my knowledge. Which is why there is no section->named.decl (thus the diagnostics ICE), as well as that in the absence of user variables without section attribute that should go into .data.rel.ro (like const int *foo = &bar; where bar isn't hidden) the compiler puts anything into .data.rel.ro section. rtld.c carefully doesn't have such variables, and uses .data.rel.ro section attribute on variables that are writable and written before relocation processing, but never after.
On 4/23/2012 12:16 PM, jakub at gcc dot gnu.org wrote: > The PA specific thing there is that PA puts rtx constant pool into .data.rel.ro > section, something that doesn't happen on i?86/x86_64/ppc/ppc64 etc. to my > knowledge. This occurs in default_elf_select_section. For example, case SECCAT_DATA_REL: sname = ".data.rel"; break; case SECCAT_DATA_REL_LOCAL: sname = ".data.rel.local"; break; case SECCAT_DATA_REL_RO: sname = ".data.rel.ro"; The category comes from here: else if (! TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) || ! TREE_CONSTANT (DECL_INITIAL (decl))) { /* Here the reloc_rw_mask is not testing whether the section should be read-only or not, but whether the dynamic link will have to do something. If so, we wish to segregate the data in order to minimize cache misses inside the dynamic linker. */ if (reloc & targetm.asm_out.reloc_rw_mask ()) ret = reloc == 1 ? SECCAT_DATA_REL_LOCAL : SECCAT_DATA_REL; else ret = SECCAT_DATA; } With PIC code, we get SECCAT_DATA_REL for the variable that caused the diagnostic ICE. It lacked a "const" qualifier.
Author: jakub Date: Tue Apr 24 06:03:43 2012 New Revision: 186741 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186741 Log: PR middle-end/52999 * varasm.c (get_section): Don't ICE for section conflicts with built-in section kinds. Modified: trunk/gcc/ChangeLog trunk/gcc/varasm.c
Author: jakub Date: Tue Apr 24 06:08:55 2012 New Revision: 186743 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186743 Log: PR middle-end/52999 * varasm.c (get_section): Don't ICE for section conflicts with built-in section kinds. Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/varasm.c
(In reply to comment #6) > This occurs in default_elf_select_section. For example, You are looking at wrong spot. What happens on this testcase is default_elf_select_rtx_section and the PA specific part of that is just that PA needs any constants that need relocations pushed into the constant pool, other targets don't.
On 4/24/2012 5:35 AM, jakub at gcc dot gnu.org wrote: > What happens on this testcase is > default_elf_select_rtx_section and the PA specific part of that is just that PA > needs any constants that need relocations pushed into the constant pool, other > targets don't. So, it's probably the procedure labels which cause the problem.
Author: danglin Date: Fri Apr 27 20:41:16 2012 New Revision: 186919 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186919 Log: PR target/52999 * config/pa/pa.c (pa_legitimate_constant_p): Don't put function labels in constant pool. Modified: trunk/gcc/ChangeLog trunk/gcc/config/pa/pa.c
Author: danglin Date: Sun May 6 20:50:06 2012 New Revision: 187216 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187216 Log: Backport from mainline: 2012-04-27 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> PR target/52999 * config/pa/pa.c (pa_legitimate_constant_p): Don't put function labels in constant pool. Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/config/pa/pa.c
Author: danglin Date: Sun May 6 20:59:10 2012 New Revision: 187217 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187217 Log: PR target/52999 * config/pa/pa.h (LEGITIMATE_CONSTANT_P): Don't put function labels in constant pool. Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/pa/pa.h
Fixed.
Author: danglin Date: Wed May 30 22:54:20 2012 New Revision: 188031 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188031 Log: 2012-05-30 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> PR target/52999 * config/pa/pa.c (TARGET_SECTION_TYPE_FLAGS): Define. (pa_section_type_flags): New. (pa_legitimate_constant_p): Revert previous change. Modified: trunk/gcc/ChangeLog trunk/gcc/config/pa/pa.c
Author: danglin Date: Wed May 30 23:03:59 2012 New Revision: 188032 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188032 Log: PR target/52999 * config/pa/pa.c (TARGET_SECTION_TYPE_FLAGS): Define. (pa_section_type_flags): New. (pa_legitimate_constant_p): Revert previous change. Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/config/pa/pa.c
Author: danglin Date: Sun Jun 3 12:41:02 2012 New Revision: 188150 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188150 Log: PR target/52999 * config/pa/pa.c (TARGET_SECTION_TYPE_FLAGS): Define. (pa_section_type_flags): New. * config/pa/pa.h (LEGITIMATE_CONSTANT_P): Revert previous change. Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/pa/pa.c branches/gcc-4_6-branch/gcc/config/pa/pa.h