.debug_line is wrong with -fpic
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro GCC |
Fix Released
|
Medium
|
Ulrich Weigand | ||
4.4 |
Fix Released
|
Medium
|
Ulrich Weigand | ||
4.5 |
Fix Released
|
Medium
|
Ulrich Weigand | ||
Linaro GCC Tracking |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
This bug is found when I was fixing linaro gdb bug LP:615989. Compile test cases in attachment, and dump .debug_line,
$ gcc -g -fpic -c test.c -o test.o
$ objdump -Wl test.o
Wrong output: (gcc-linaro-
Line Number Statements:
Extended opcode 2: set Address to 0x0
Advance Line by 9 to 10
Copy
Special opcode 49: advance Address by 6 to 0x6 and Line by 2 to 12 // <-- [1]
Special opcode 45: advance Address by 6 to 0xc and Line by -2 to 10
Special opcode 20: advance Address by 2 to 0xe and Line by 1 to 11
Special opcode 62: advance Address by 8 to 0x16 and Line by 1 to 12
Special opcode 76: advance Address by 10 to 0x20 and Line by 1 to 13
Advance PC by 16 to 0x30
Extended opcode 1: End of Sequence
The wrong opcode in .debug_line leads to hitting breakpoint set on function pendfunc1 on line 12 rather than line 11. As analyzed in comment #2 LP:615989, instruction on address 0x6 is generated from RTL 'pic_load_
Right output: (gcc-linaro-
Line Number Statements:
Extended opcode 2: set Address to 0x0
Advance Line by 9 to 10
Copy
Special opcode 62: advance Address by 8 to 0x8 and Line by 1 to 11
Special opcode 62: advance Address by 8 to 0x10 and Line by 1 to 12
Special opcode 76: advance Address by 10 to 0x1a and Line by 1 to 13
Advance PC by 14 to 0x28
Extended opcode 1: End of Sequence
Related branches
- Linaro Toolchain Developers: Pending requested
-
Diff: 41 lines (+15/-1)2 files modifiedChangeLog.linaro (+9/-0)
gcc/config/arm/arm.c (+6/-1)
- Linaro Toolchain Developers: Pending requested
-
Diff: 40 lines (+14/-1)2 files modifiedChangeLog.linaro (+8/-0)
gcc/config/arm/arm.c (+6/-1)
Changed in gcc-linaro: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in gcc-linaro-tracking: | |
status: | Fix Committed → Fix Released |
The problem here is that the require_ pic_register routine generates code that will be placed immediately at function entry, but does not set the location information that would cause these insns to be considered part of the prologue. Therefore, they'll just get the line number of whatever statement happened to first use the pic register.
The reason why this no longer shows up in 4.5 is that just to determine the address of a string constant, we actually do not really need the pic register anyway, and the Linaro 4.5 contains a backport of the patch that optimized code generation to avoid the pic register in this case:
2010-07-24 Sandra Loosemore <email address hidden>
Backport from mainline:
2010-04-10 Wei Guozhi <email address hidden>
PR target/42601 static_ addr): New function.
(legitimize_ pic_address) : Call arm_pic_static_addr when it detects
(arm_output_ addr_const_ extra): Output expression for new pattern. SYMBOL_ OFFSET) : New unspec symbol.
gcc/
* config/arm/arm.c (arm_pic_
a static symbol.
* config/arm/arm.md (UNSPEC_
There's two options to fix this problem:
- We might want to backport the above patch to 4.4 as well (it is an additional performance enhancement anyway)
- We might want to fix the underlying problem with require_ pic_register, since in more complex code the same problem could re-occur in 4.5 (or even mainline).