[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/24992] New: RISC-V: partial relaxing against global pointer with
From: |
yitingwang16 at outlook dot com |
Subject: |
[Bug ld/24992] New: RISC-V: partial relaxing against global pointer with sdata section alignment |
Date: |
Wed, 11 Sep 2019 17:00:40 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=24992
Bug ID: 24992
Summary: RISC-V: partial relaxing against global pointer with
sdata section alignment
Product: binutils
Version: 2.30
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: yitingwang16 at outlook dot com
Target Milestone: ---
A simple test case below to trigger the weird behavior of GP linker relaxation:
$ cat test.c
char __attribute__ ((aligned(2))) x = 'x';
char a = 1;
char b = 2;
char c = 3;
char d = 4;
char e = 5;
int main()
{
return a + b + c + d + e;
}
$ riscv64-unknown-linux-gnu-gcc -nostdlib -o test test.c
HI20/LO12 relocations that reference c, d and e are relaxed against gp:
$ riscv64-unknown-linux-gnu-objdump -D test
00000000000100e8 <main>:
100e8: 1141 addi sp,sp,-16
100ea: e422 sd s0,8(sp)
100ec: 0800 addi s0,sp,16
100ee: 67c5 lui a5,0x11
100f0: 1317c783 lbu a5,305(a5) # 11131 <a>
100f4: 0007871b sext.w a4,a5
100f8: 67c5 lui a5,0x11
100fa: 1327c783 lbu a5,306(a5) # 11132 <b>
100fe: 2781 sext.w a5,a5
10100: 9fb9 addw a5,a5,a4
10102: 0007871b sext.w a4,a5
10106: 8031c783 lbu a5,-2045(gp) # 11133 <c>
1010a: 2781 sext.w a5,a5
1010c: 9fb9 addw a5,a5,a4
1010e: 0007871b sext.w a4,a5
10112: 8041c783 lbu a5,-2044(gp) # 11134 <d>
10116: 2781 sext.w a5,a5
10118: 9fb9 addw a5,a5,a4
1011a: 0007871b sext.w a4,a5
1011e: 8051c783 lbu a5,-2043(gp) # 11135 <e>
10122: 2781 sext.w a5,a5
10124: 9fb9 addw a5,a5,a4
10126: 2781 sext.w a5,a5
10128: 853e mv a0,a5
1012a: 6422 ld s0,8(sp)
1012c: 0141 addi sp,sp,16
1012e: 8082 ret
Change test.c line#1 to:
char __attribute__ ((aligned(4))) x = 'x';
Only HI20/LO12 relocation that references e is relaxed against gp:
$ riscv64-unknown-linux-gnu-objdump -D test
00000000000100e8 <main>:
100e8: 1141 addi sp,sp,-16
100ea: e422 sd s0,8(sp)
100ec: 0800 addi s0,sp,16
100ee: 67c5 lui a5,0x11
100f0: 1357c783 lbu a5,309(a5) # 11135 <a>
100f4: 0007871b sext.w a4,a5
100f8: 67c5 lui a5,0x11
100fa: 1367c783 lbu a5,310(a5) # 11136 <b>
100fe: 2781 sext.w a5,a5
10100: 9fb9 addw a5,a5,a4
10102: 0007871b sext.w a4,a5
10106: 67c5 lui a5,0x11
10108: 1377c783 lbu a5,311(a5) # 11137 <c>
1010c: 2781 sext.w a5,a5
1010e: 9fb9 addw a5,a5,a4
10110: 0007871b sext.w a4,a5
10114: 67c5 lui a5,0x11
10116: 1387c783 lbu a5,312(a5) # 11138 <d>
1011a: 2781 sext.w a5,a5
1011c: 9fb9 addw a5,a5,a4
1011e: 0007871b sext.w a4,a5
10122: 8051c783 lbu a5,-2043(gp) # 11139 <e>
10126: 2781 sext.w a5,a5
10128: 9fb9 addw a5,a5,a4
1012a: 2781 sext.w a5,a5
1012c: 853e mv a0,a5
1012e: 6422 ld s0,8(sp)
10130: 0141 addi sp,sp,16
10132: 8082 ret
Change test.c line#1 to:
char __attribute__ ((aligned(8))) x = 'x';
Then there is no relaxation against gp.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/24992] New: RISC-V: partial relaxing against global pointer with sdata section alignment,
yitingwang16 at outlook dot com <=
- [Bug ld/24992] RISC-V: partial relaxing against global pointer with sdata section alignment, wilson at gcc dot gnu.org, 2019/09/11
- [Bug ld/24992] RISC-V: partial relaxing against global pointer with sdata section alignment, wilson at gcc dot gnu.org, 2019/09/11
- [Bug ld/24992] RISC-V: partial relaxing against global pointer with sdata section alignment, yitingwang16 at outlook dot com, 2019/09/12
- [Bug ld/24992] RISC-V: partial relaxing against global pointer with sdata section alignment, wilson at gcc dot gnu.org, 2019/09/12
- [Bug ld/24992] RISC-V: partial relaxing against global pointer with sdata section alignment, yitingwang16 at outlook dot com, 2019/09/16
- [Bug ld/24992] RISC-V: partial relaxing against global pointer with sdata section alignment, wilson at gcc dot gnu.org, 2019/09/17