[PATCH] D99754: [LLD][ELF][AVR] Propagate ELF flags to the linked image
LemonBoy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 12:01:11 PDT 2021
LemonBoy updated this revision to Diff 335896.
LemonBoy added a comment.
Ping (& fix one small style issue pointed out by clang-tidy)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99754/new/
https://reviews.llvm.org/D99754
Files:
lld/ELF/Arch/AVR.cpp
llvm/include/llvm/BinaryFormat/ELF.h
Index: llvm/include/llvm/BinaryFormat/ELF.h
===================================================================
--- llvm/include/llvm/BinaryFormat/ELF.h
+++ llvm/include/llvm/BinaryFormat/ELF.h
@@ -484,7 +484,12 @@
EF_AVR_ARCH_XMEGA4 = 104,
EF_AVR_ARCH_XMEGA5 = 105,
EF_AVR_ARCH_XMEGA6 = 106,
- EF_AVR_ARCH_XMEGA7 = 107
+ EF_AVR_ARCH_XMEGA7 = 107,
+
+ EF_AVR_ARCH_MASK = 0x7f, // EF_AVR_ARCH_xxx selection mask
+
+ EF_AVR_LINKRELAX_PREPARED = 0x80, // The file is prepared for linker
+ // relaxation to be applied
};
// ELF Relocation types for AVR
Index: lld/ELF/Arch/AVR.cpp
===================================================================
--- lld/ELF/Arch/AVR.cpp
+++ lld/ELF/Arch/AVR.cpp
@@ -43,6 +43,7 @@
class AVR final : public TargetInfo {
public:
AVR();
+ uint32_t calcEFlags() const override;
RelExpr getRelExpr(RelType type, const Symbol &s,
const uint8_t *loc) const override;
void relocate(uint8_t *loc, const Relocation &rel,
@@ -196,3 +197,30 @@
static AVR target;
return ⌖
}
+
+static uint32_t getEFlags(InputFile *file) {
+ return cast<ObjFile<ELF32LE>>(file)->getObj().getHeader().e_flags;
+}
+
+uint32_t AVR::calcEFlags() const {
+ assert(!objectFiles.empty());
+
+ uint32_t flags = getEFlags(objectFiles[0]);
+ bool hasLinkerRelaxFlag = flags & EF_AVR_LINKRELAX_PREPARED;
+
+ for (InputFile *f : makeArrayRef(objectFiles).slice(1)) {
+ uint32_t objFlags = getEFlags(f);
+
+ if ((objFlags & EF_AVR_ARCH_MASK) != (flags & EF_AVR_ARCH_MASK))
+ error(toString(f) +
+ ": cannot link object files with incompatible target ISA");
+
+ if (!(objFlags & EF_AVR_LINKRELAX_PREPARED))
+ hasLinkerRelaxFlag = false;
+ }
+
+ if (!hasLinkerRelaxFlag)
+ flags &= ~EF_AVR_LINKRELAX_PREPARED;
+
+ return flags;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99754.335896.patch
Type: text/x-patch
Size: 1859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210407/d396e5b5/attachment.bin>
More information about the llvm-commits
mailing list