[llvm] 165f707 - [AVR] Don't adjust addresses by 2 for absolute values
Ayke van Laethem via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 11:32:36 PST 2020
Author: Ayke van Laethem
Date: 2020-02-26T20:32:24+01:00
New Revision: 165f707f9d0fb227e30b9a57d8ceb27f55032f90
URL: https://github.com/llvm/llvm-project/commit/165f707f9d0fb227e30b9a57d8ceb27f55032f90
DIFF: https://github.com/llvm/llvm-project/commit/165f707f9d0fb227e30b9a57d8ceb27f55032f90.diff
LOG: [AVR] Don't adjust addresses by 2 for absolute values
Adjusting by 2 breaks DWARF output. With this fix, programs start to
compile and produce valid DWARF output.
Differential Revision: https://reviews.llvm.org/D74213
Added:
llvm/test/MC/AVR/relocations-abs.s
Modified:
llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
index e92b16c8ee9d..1a741c907750 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
@@ -244,8 +244,18 @@ void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup,
// To handle both cases, we simply un-adjust the temporary label
// case so it acts like all other labels.
if (const MCSymbolRefExpr *A = Target.getSymA()) {
- if (A->getSymbol().isTemporary())
- Value += 2;
+ if (A->getSymbol().isTemporary()) {
+ switch (Kind) {
+ case FK_Data_1:
+ case FK_Data_2:
+ case FK_Data_4:
+ case FK_Data_8:
+ // Don't shift value for absolute addresses.
+ break;
+ default:
+ Value += 2;
+ }
+ }
}
switch (Kind) {
diff --git a/llvm/test/MC/AVR/relocations-abs.s b/llvm/test/MC/AVR/relocations-abs.s
new file mode 100644
index 000000000000..1055ed51310a
--- /dev/null
+++ b/llvm/test/MC/AVR/relocations-abs.s
@@ -0,0 +1,8 @@
+; RUN: llvm-mc -filetype=obj -triple=avr %s | llvm-objdump -dr - | FileCheck %s
+
+; CHECK: bar:
+; CHECK-NEXT: 00 00 nop
+; CHECK-NEXT: R_AVR_16 .text+0x2
+bar:
+ .short 1f
+1:
More information about the llvm-commits
mailing list