Bug 21516 - PPC VLE linker produces broken object
Summary: PPC VLE linker produces broken object
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-24 15:53 UTC by Alexander Fedotov
Modified: 2017-10-02 06:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
reproducible test case (47.32 KB, application/x-tar)
2017-05-24 15:53 UTC, Alexander Fedotov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Fedotov 2017-05-24 15:53:05 UTC
Created attachment 10067 [details]
reproducible test case

Hi
It seems since from 2.25 version linker does something with VLE relocations wrong. Issue not present on 2.24.90.

Running LD with certain command line and disassemble resulting ELF gives:

02000000 <__init>:
 2000000:	18 21 06 f0 	e_stwu  r1,-16(r1)
 2000004:	00 80       	se_mflr r0
 2000006:	54 01 00 14 	e_stw   r0,20(r1)
 200000a:	00 00       	se_illegal
 200000c:	50 01 00 14 	e_lwz   r0,20(r1)
 2000010:	00 90       	se_mtlr r0
 2000012:	20 f1       	se_addi r1,16
 2000014:	00 04       	se_blr
 2000016:	50 01 81 00 	e_lwz   r0,0(r1)

se_illegal instruction appears in ELF multiple times and breaks runtime execution.

Tracked down differences 2.24.90 vs 2.25 I found that check "branch in range" at ppc_elf_relax_section() somehow affects final result. E.g. 2.24.90 produces warning on output:
test.o: In function `main':
test.c:(.text+0x10): relocation truncated to fit: R_PPC_VLE_REL24 against symbol `foo' defined in .ram_code section in test.o

while 2.25 is not.

Attached ld_se_illegal.tar which contains objects and linker script.
Comment 1 Alexander Fedotov 2017-05-25 15:11:01 UTC
Hmm
Seems like I have another source tree. Main line doesn't have such issue.

Please ignore for a while.
Comment 2 Alan Modra 2017-10-02 06:38:51 UTC
Ignoring