Bug 55033 - [4.8/4.9/4.10 Regression] PowerPC section type conflict error
Summary: [4.8/4.9/4.10 Regression] PowerPC section type conflict error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.0
: P4 normal
Target Milestone: 4.8.1
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-23 12:53 UTC by Sebastian Huber
Modified: 2014-06-12 15:42 UTC (History)
7 users (show)

See Also:
Host:
Target: powerpc-rtems4.11 powerpc-eabi
Build:
Known to work: 4.5.5
Known to fail: 4.6.4, 4.7.3, 4.8.0
Last reconfirmed: 2013-05-10 00:00:00


Attachments
Pre-processed C++ test file. (54.51 KB, text/plain)
2012-10-23 12:53 UTC, Sebastian Huber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Huber 2012-10-23 12:53:49 UTC
Created attachment 28513 [details]
Pre-processed C++ test file.

With GCC 4.6, 4.7, and 4.8 we have this error (GCC 4.5 works):

powerpc-rtems4.11-g++ -S -mcpu=8540 -msoft-float -meabi -msdata -fno-common test.ii
dma_intf.CPP:264:133: error: elm_dsc_mod_file_ causes a section type conflict
Comment 1 Sebastian Huber 2012-10-23 13:20:28 UTC
This error is also present in the PowerPC EABI configuration (the RTEMS and EABI configurations are roughly the same):

powerpc-unknown-eabi-g++ --version --verbose
Using built-in specs.
COLLECT_GCC=powerpc-unknown-eabi-g++
COLLECT_LTO_WRAPPER=/home/sh/install-eabi/lib/gcc/powerpc-unknown-eabi/4.8.0/lto-wrapper
powerpc-unknown-eabi-g++ (GCC) 4.8.0 20121023 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Target: powerpc-unknown-eabi
Configured with: /home/sh/archive/gcc-git/configure --prefix=/home/sh/install-eabi --target=powerpc-unknown-eabi  --verbose --with-gnu-as --with-gnu-ld --with-newlib --disable-libssp --enable-languages=c,c++
Thread model: single
gcc version 4.8.0 20121023 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='--version' '-v'
 /home/sh/install-eabi/lib/gcc/powerpc-unknown-eabi/4.8.0/cc1 -quiet -v help-dummy -quiet -dumpbase help-dummy -auxbase help-dummy -version --version -o /tmp/ccbQTCaZ.s
GNU C (GCC) version 4.8.0 20121023 (experimental) (powerpc-unknown-eabi)
        compiled by GNU C version 4.6.2, GMP version 5.0.5, MPFR version 3.1.1, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
COLLECT_GCC_OPTIONS='--version' '-v'
 /home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/../../../../powerpc-unknown-eabi/bin/as -v -mppc -many --version -o /tmp/ccYVhGeE.o /tmp/ccbQTCaZ.s
GNU assembler version 2.22.52 (powerpc-unknown-eabi) using BFD version (GNU Binutils) 2.22.52.20120727
GNU assembler (GNU Binutils) 2.22.52.20120727
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `powerpc-unknown-eabi'.
COMPILER_PATH=/home/sh/install-eabi/lib/gcc/powerpc-unknown-eabi/4.8.0/:/home/sh/install-eabi/lib/gcc/powerpc-unknown-eabi/4.8.0/:/home/sh/install-eabi/lib/gcc/powerpc-unknown-eabi/:/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/:/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/:/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/../../../../powerpc-unknown-eabi/bin/
LIBRARY_PATH=/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/:/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/../../../../powerpc-unknown-eabi/lib/
COLLECT_GCC_OPTIONS='--version' '-v'
 /home/sh/install-eabi/lib/gcc/powerpc-unknown-eabi/4.8.0/collect2 -V -dn -Bstatic --version ecrti.o crtbegin.o -L/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0 -L/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/../../../../powerpc-unknown-eabi/lib /tmp/ccYVhGeE.o -lgcc -lc -lgcc crtend.o ecrtn.o
collect2 version 4.8.0 20121023 (experimental)
/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/../../../../powerpc-unknown-eabi/bin/ld -V -dn -Bstatic --version ecrti.o crtbegin.o -L/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0 -L/home/sh/install-eabi/lib64/gcc/powerpc-unknown-eabi/4.8.0/../../../../powerpc-unknown-eabi/lib /tmp/ccYVhGeE.o -lgcc -lc -lgcc crtend.o ecrtn.o
GNU ld (GNU Binutils) 2.22.52.20120727
  Supported emulations:
   elf32ppc
   elf32ppclinux
   elf32ppcsim
GNU ld (GNU Binutils) 2.22.52.20120727
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Comment 2 Sebastian Huber 2012-10-23 15:03:37 UTC
#0  default_elf_select_section (decl=0x7ffff72b92d0, reloc=0, align=32) at /home/sh/archive/gcc-git/gcc/varasm.c:6251
#1  0x0000000000c57d4e in get_constant_section (align=<optimized out>, exp=0x7ffff72b92d0) at /home/sh/archive/gcc-git/gcc/varasm.c:3021
#2  build_constant_desc (exp=0x7ffff72b92d0) at /home/sh/archive/gcc-git/gcc/varasm.c:3091
#3  0x0000000000c5c3f0 in tree_output_constant_def (exp=0x7ffff72b92d0) at /home/sh/archive/gcc-git/gcc/varasm.c:3282
#4  0x00000000008fe0a4 in gimplify_init_constructor (expr_p=0x7fffffffd108, pre_p=0x7fffffffd2e8, post_p=0x7fffffffd088, want_value=false, notify_temp_creation=false) at /home/sh/archive/gcc-git/gcc/gimplify.c:4085
#5  0x00000000008feb16 in gimplify_modify_expr_rhs (expr_p=0x7fffffffd108, from_p=0x7ffff68ed110, to_p=0x7ffff68ed108, pre_p=0x7fffffffd2e8, post_p=0x7fffffffd088, want_value=false) at /home/sh/archive/gcc-git/gcc/gimplify.c:4530
#6  0x00000000009010ef in gimplify_modify_expr (want_value=false, post_p=0x7fffffffd088, pre_p=0x7fffffffd2e8, expr_p=0x7fffffffd108) at /home/sh/archive/gcc-git/gcc/gimplify.c:4840
#7  gimplify_expr (expr_p=0x7fffffffd108, pre_p=0x7fffffffd2e8, post_p=0x7fffffffd088, gimple_test_f=0x8f7b70 <is_gimple_stmt(tree)>, fallback=0) at /home/sh/archive/gcc-git/gcc/gimplify.c:7167
#8  0x0000000000907429 in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x7fffffffd2e8) at /home/sh/archive/gcc-git/gcc/gimplify.c:5700
#9  0x0000000000908fe3 in gimplify_and_add (t=0x7ffff68ed0f0, seq_p=<optimized out>) at /home/sh/archive/gcc-git/gcc/gimplify.c:371
#10 0x000000000090a0c0 in gimplify_decl_expr (stmt_p=<optimized out>, seq_p=0x7fffffffd2e8) at /home/sh/archive/gcc-git/gcc/gimplify.c:1484
#11 0x00000000008ffcd1 in gimplify_expr (expr_p=0x7ffff68bebf8, pre_p=0x7fffffffd2e8, post_p=0x7fffffffd228, gimple_test_f=0x8f7b70 <is_gimple_stmt(tree)>, fallback=0) at /home/sh/archive/gcc-git/gcc/gimplify.c:7334
#12 0x0000000000907429 in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x7fffffffd2e8) at /home/sh/archive/gcc-git/gcc/gimplify.c:5700
#13 0x0000000000908c88 in gimplify_cleanup_point_expr (expr_p=0x7ffff72b93d0, pre_p=0x7fffffffd5e8) at /home/sh/archive/gcc-git/gcc/gimplify.c:5477
#14 0x00000000008ffa71 in gimplify_expr (expr_p=0x7ffff72b93d0, pre_p=0x7fffffffd5e8, post_p=0x7fffffffd408, gimple_test_f=0x8f7b70 <is_gimple_stmt(tree)>, fallback=0) at /home/sh/archive/gcc-git/gcc/gimplify.c:7504
#15 0x0000000000907429 in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x7fffffffd5e8) at /home/sh/archive/gcc-git/gcc/gimplify.c:5700
#16 0x00000000008ff98c in gimplify_statement_list (pre_p=0x7fffffffd5e8, expr_p=0x7ffff656d8f0) at /home/sh/archive/gcc-git/gcc/gimplify.c:1537
#17 gimplify_expr (expr_p=0x7ffff656d8f0, pre_p=0x7fffffffd5e8, post_p=0x7fffffffd558, gimple_test_f=0x8f7b70 <is_gimple_stmt(tree)>, fallback=0) at /home/sh/archive/gcc-git/gcc/gimplify.c:7556
#18 0x0000000000907429 in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x7fffffffd5e8) at /home/sh/archive/gcc-git/gcc/gimplify.c:5700
#19 0x0000000000908316 in gimplify_bind_expr (expr_p=0x7ffff62f2b98, pre_p=0x7fffffffd7f8) at /home/sh/archive/gcc-git/gcc/gimplify.c:1230
#20 0x0000000000900787 in gimplify_expr (expr_p=0x7ffff62f2b98, pre_p=0x7fffffffd7f8, post_p=0x7fffffffd718, gimple_test_f=0x8f7b70 <is_gimple_stmt(tree)>, fallback=0) at /home/sh/archive/gcc-git/gcc/gimplify.c:7338
#21 0x0000000000907429 in gimplify_stmt (stmt_p=<optimized out>, seq_p=0x7fffffffd7f8) at /home/sh/archive/gcc-git/gcc/gimplify.c:5700
#22 0x0000000000907522 in gimplify_body (fndecl=0x7ffff62f2b00, do_parms=true) at /home/sh/archive/gcc-git/gcc/gimplify.c:8203
#23 0x0000000000907a16 in gimplify_function_tree (fndecl=0x7ffff62f2b00) at /home/sh/archive/gcc-git/gcc/gimplify.c:8337
#24 0x00000000007adc98 in cgraph_analyze_function (node=0x7ffff679f6f0) at /home/sh/archive/gcc-git/gcc/cgraphunit.c:643
#25 0x00000000007b0ad7 in cgraph_analyze_functions () at /home/sh/archive/gcc-git/gcc/cgraphunit.c:928
#26 0x00000000007b1991 in finalize_compilation_unit () at /home/sh/archive/gcc-git/gcc/cgraphunit.c:2071
#27 0x00000000005d46cc in cp_write_global_declarations () at /home/sh/archive/gcc-git/gcc/cp/decl2.c:4286
#28 0x0000000000a55b8d in compile_file () at /home/sh/archive/gcc-git/gcc/toplev.c:560
#29 0x0000000000a577f2 in do_compile () at /home/sh/archive/gcc-git/gcc/toplev.c:1866
#30 toplev_main (argc=18, argv=0x7fffffffdb28) at /home/sh/archive/gcc-git/gcc/toplev.c:1942
#31 0x00007ffff761223d in __libc_start_main () from /lib64/libc.so.6
#32 0x00000000004ebbcd in _start () at ../sysdeps/x86_64/elf/start.S:113

The problem is that something in GCC calls default_elf_select_section(decl, reloc, align) with categorize_decl_for_section(decl, reloc) == SECCAT_SRODATA.  This in turn calls get_named_section (decl=0x0 == NULL_TREE, name=0x101b0bc ".sdata2", reloc=0) which leads to (gcc/varasm.c):

[...]
unsigned int
default_section_type_flags (tree decl, const char *name, int reloc)
{
  unsigned int flags;

  if (decl && TREE_CODE (decl) == FUNCTION_DECL)
    flags = SECTION_CODE;
  else if (decl)
    {
      enum section_category category
	= categorize_decl_for_section (decl, reloc);
      if (decl_readonly_section_1 (category))
	flags = 0;
      else if (category == SECCAT_DATA_REL_RO
	       || category == SECCAT_DATA_REL_RO_LOCAL)
	flags = SECTION_WRITE | SECTION_RELRO;
      else
	flags = SECTION_WRITE;
    }
  else
    {
      flags = SECTION_WRITE;
      if (strcmp (name, ".data.rel.ro") == 0
	  || strcmp (name, ".data.rel.ro.local") == 0)
	flags |= SECTION_RELRO;
    }
[...]

Now we have SECTION_WRITE set in flags (this is quite wrong for SECCAT_SRODATA from my point of view).  Which leads to the section type conflict in the next call to get_section (name=0x101b0bc ".sdata2", flags=0, decl=0x7ffff65795f0).
Comment 3 David Fang 2012-11-06 09:26:38 UTC
Would this be testable on powerpc-apple-darwin8?
Comment 4 Sebastian Huber 2012-11-06 13:18:15 UTC
(In reply to comment #3)
> Would this be testable on powerpc-apple-darwin8?

See also

http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02051.html

The -mcpu=8540 -msdata=eabi option is important.  I don't know how to trigger this bug without the -mcpu=8540 option.
Comment 5 Joel Sherrill 2013-03-26 16:11:46 UTC
Per http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00970.html would it be OK to get this committed to the 4.8 branch and head?
Comment 6 Jakub Jelinek 2013-04-12 15:16:23 UTC
GCC 4.6.4 has been released and the branch has been closed.
Comment 8 Pat Haugen 2013-06-12 15:29:26 UTC
The testcase added 6/7, gcc.target/powerpc/pr55033.c, fails on powerpc64-linux.

spawn -ignore SIGHUP /home/pthaugen/work/build/gcc/trunk/gcc/xgcc -B/home/pthaugen/work/build/gcc/trunk/gcc/ /home/pthaugen/src/gcc/trunk/gcc/gcc/testsuite/gcc.target/powerpc/pr55033.c -fno-diagnostics-show-caret -fdiagnostics-color=never -mcpu=8540 -msoft-float -msdata=eabi -G 8 -fno-common -S -m32 -o pr55033.s^M
/home/pthaugen/src/gcc/trunk/gcc/gcc/testsuite/gcc.target/powerpc/pr55033.c:1:0: error: -msdata=eabi and -mcall-linux are incompatible^M
compiler exited with status 1
output is:
/home/pthaugen/src/gcc/trunk/gcc/gcc/testsuite/gcc.target/powerpc/pr55033.c:1:0: error: -msdata=eabi and -mcall-linux are incompatible^M

FAIL: gcc.target/powerpc/pr55033.c (test for excess errors)
Comment 9 Sebastian Huber 2013-06-13 09:10:53 UTC
If I run the tests on gcc1-power7.osuosl.org (which is target powerpc64-unknown-linux-gnu), then the PR55033 test case shows up as UNSUPPORTED:

grep -r pr55033 .
./gcc/testsuite/gcc/gcc.sum:UNSUPPORTED: gcc.target/powerpc/pr55033.c
./gcc/testsuite/gcc/gcc.log:UNSUPPORTED: gcc.target/powerpc/pr55033.c
./gcc/testsuite/gcc11/gcc.log.sep:UNSUPPORTED: gcc.target/powerpc/pr55033.c
./gcc/testsuite/gcc11/gcc.sum.sep:UNSUPPORTED: gcc.target/powerpc/pr55033.c
Comment 10 Segher Boessenkool 2013-06-13 15:09:57 UTC
The testcase needs to add -meabi to fix #8.

Wrt #9: it seems you only tested 64-bit mode, -meabi is supported
only in 32-bit mode.
Comment 11 Chung-Ju Wu 2013-07-02 04:39:35 UTC
(In reply to Segher Boessenkool from comment #10)
> The testcase needs to add -meabi to fix #8.
> 
> Wrt #9: it seems you only tested 64-bit mode, -meabi is supported
> only in 32-bit mode.

Sebastian provided a testcase fix accordingly and got approval:
http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00977.html

The fix has been committed into Rev.200191:
http://gcc.gnu.org/r200191
Comment 12 Richard Biener 2014-06-12 13:43:43 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 13 Alan Modra 2014-06-12 15:42:06 UTC
Fixed in 4.8.1