Bug 50313 - ARM: PIC code references a non-existant label
Summary: ARM: PIC code references a non-existant label
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: 4.6.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 03:56 UTC by Michael Hope
Modified: 2023-06-06 04:17 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-linux-gnueabi
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-13 00:00:00


Attachments
Preprocessed source (38.76 KB, application/x-gzip)
2011-09-07 03:56 UTC, Michael Hope
Details
smaller testcase (2.98 KB, text/x-csrc)
2012-01-13 12:06 UTC, Ramana Radhakrishnan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Hope 2011-09-07 03:56:48 UTC
Created attachment 25211 [details]
Preprocessed source

Building gmime with GCC 4.6.1 for ARM gives the following error:

michaelh@ursa1:~/linaro/bugs$ gcc -c -O2 -fPIC -save-temps gmime2.i
gmime2.s: Assembler messages:
gmime2.s:1007: Error: can't resolve `.rodata' {.rodata section} - `.LPIC18' {*UND* section}

The assembler is correct - the code references a label which doesn't exist.

The suspicious code is around:
 bl g_hash_table_new(PLT)
 mov sl, r0
 add r0, sp, #32
 bl g_mime_decode_lwsp(PLT)
 ldr r3, .L146+24
 ldr r1, [sp, #4]
 str r3, [sp, #16]
 ldr r3, [sp, #32]
...
.L146:
...
 .word .LANCHOR0-(.LPIC18+4)

The 'ldr r3, .L146+24' references the offset. The value is spilt to the stack before the normal `add r3, pc` and doesn't seem to be used afterwards.

The work-around is to compile at -O1 or -O3. The fault also exists in gcc-4.6.1. It does not exist in gcc-4.5.3 or trunk r178025.

This is in a Cortex-A9+NEON+Thumb-2 configuration.
Comment 1 Mikael Pettersson 2011-09-07 05:55:26 UTC
I suspect this is a dupe of PR48308.
Comment 2 Ramana Radhakrishnan 2011-09-13 06:31:39 UTC
Looks like a DUP of PR48308.

*** This bug has been marked as a duplicate of bug 48308 ***
Comment 3 Ramana Radhakrishnan 2012-01-13 12:03:14 UTC
reopening this as the proposed fix for 48308 doesn't appear to fix the issue and the same problem in combine doesn't seem to happen in this case. 

Ramana
Comment 4 Ramana Radhakrishnan 2012-01-13 12:06:33 UTC
Created attachment 26314 [details]
smaller testcase

Better reduced testcase. Fails on trunk with -Os -fPIC -mcpu=arm9tdmi or -Os -fPIC -mthumb -mcpu=cortex-a9
Comment 5 Ramana Radhakrishnan 2012-01-20 09:22:21 UTC
Author: ramana
Date: Fri Jan 20 09:22:14 2012
New Revision: 183328

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183328
Log:

Fix PR target/50313


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c
    trunk/gcc/config/arm/arm.md
Comment 6 Ramana Radhakrishnan 2012-01-30 14:35:10 UTC
Author: ramana
Date: Mon Jan 30 14:35:05 2012
New Revision: 183727

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183727
Log:

Fix PR target/50313


2012-01-30  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>

	Backport from mainline.
        2012-01-20  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>

	PR target/50313
	* config/arm/arm.c (arm_load_pic_register): Use
	gen_pic_load_addr_unified. Delete calls to gen_pic_load_addr_32bit
	, gen_pic_add_dot_plus_eight and gen_pic_add_dot_plus_four.
	(arm_pic_static_addr): Likewise.
	(arm_rtx_costs_1): Adjust cost for UNSPEC_PIC_UNIFIED.
	(arm_note_pic_base): Handle UNSPEC_PIC_UNIFIED.
	* config/arm/arm.md (UNSPEC_PIC_UNIFIED): Define.
	(pic_load_addr_unified): New.



Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/arm/arm.c
    branches/gcc-4_6-branch/gcc/config/arm/arm.md
Comment 7 Ramana Radhakrishnan 2012-01-30 14:37:44 UTC
Backported now to GCC 4.6 branch.


Ramana