[llvm] r347074 - [MSP430] Use R_MSP430_16_BYTE type for FK_Data_2 fixup
Anton Korobeynikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 16 11:20:51 PST 2018
Author: asl
Date: Fri Nov 16 11:20:51 2018
New Revision: 347074
URL: http://llvm.org/viewvc/llvm-project?rev=347074&view=rev
Log:
[MSP430] Use R_MSP430_16_BYTE type for FK_Data_2 fixup
Linker fails to link example like this (simplified case from newlib
sources):
$ cat test.c
extern const char _ctype_b[];
struct _t { char *ptr; };
struct _t T = { ((char *) _ctype_b + 3) };
$ cat ctype.c
char _ctype_b[4] = { 0, 0, 0, 0 };
LD: test.o:(.data+0x0): warning: internal error: unsupported relocation error
We also follow gnu toolchain here, where 2-byte relocation mapped to
R_MSP430_16_BYTE, instead of R_MSP430_16.
Patch by Kristina Bessonova!
Differential Revision: https://reviews.llvm.org/D54620
Modified:
llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430ELFObjectWriter.cpp
llvm/trunk/test/MC/MSP430/reloc.s
Modified: llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430ELFObjectWriter.cpp?rev=347074&r1=347073&r2=347074&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430ELFObjectWriter.cpp Fri Nov 16 11:20:51 2018
@@ -34,7 +34,7 @@ protected:
// Translate fixup kind to ELF relocation type.
switch ((unsigned)Fixup.getKind()) {
case FK_Data_1: return ELF::R_MSP430_8;
- case FK_Data_2: return ELF::R_MSP430_16;
+ case FK_Data_2: return ELF::R_MSP430_16_BYTE;
case FK_Data_4: return ELF::R_MSP430_32;
case MSP430::fixup_32: return ELF::R_MSP430_32;
case MSP430::fixup_10_pcrel: return ELF::R_MSP430_10_PCREL;
Modified: llvm/trunk/test/MC/MSP430/reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MSP430/reloc.s?rev=347074&r1=347073&r2=347074&view=diff
==============================================================================
--- llvm/trunk/test/MC/MSP430/reloc.s (original)
+++ llvm/trunk/test/MC/MSP430/reloc.s Fri Nov 16 11:20:51 2018
@@ -20,3 +20,8 @@
jmp foo
; CHECK: jmp foo ; encoding: [A,0b001111AA]
; CHECK: ; fixup A - offset: 0, value: foo, kind: fixup_10_pcrel
+
+; RUN: llvm-mc -filetype=obj -triple msp430 < %s | llvm-readobj -r \
+; RUN: | FileCheck -check-prefix=RELOC %s
+.short _ctype+3
+; RELOC: R_MSP430_16_BYTE _ctype 0x3
More information about the llvm-commits
mailing list