[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
This commit is contained in:
Ayke van Laethem 2020-02-07 13:06:40 +01:00
parent 56f7de5baa
commit 165f707f9d
No known key found for this signature in database
GPG Key ID: E97FF5335DFDFDED
2 changed files with 20 additions and 2 deletions

View File

@ -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) {

View File

@ -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: