summaryrefslogtreecommitdiff
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-14 18:50:02 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-07-14 18:50:02 +0000
commit1f917f69ff07f09b6dbb670971f57f8efe718b84 (patch)
tree99293cbc1411737cd995dac10a99b2c40ef0944c /lld/ELF/InputSection.cpp
parent145449b1e420787bb99721a429341fa6be3adfb6 (diff)
Vendor import of llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f.vendor/llvm-project/llvmorg-15-init-16436-g18a6ab5b8d1f
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 97fc18b58244..8fe36eca6a4b 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -72,12 +72,8 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
// If SHF_COMPRESSED is set, parse the header. The legacy .zdebug format is no
// longer supported.
- if (flags & SHF_COMPRESSED) {
- if (!zlib::isAvailable())
- error(toString(file) + ": contains a compressed section, " +
- "but zlib is not available");
+ if (flags & SHF_COMPRESSED)
invokeELFT(parseCompressedHeader);
- }
}
// Drop SHF_GROUP bit unless we are producing a re-linkable object file.
@@ -115,17 +111,17 @@ size_t InputSectionBase::getSize() const {
void InputSectionBase::uncompress() const {
size_t size = uncompressedSize;
- char *uncompressedBuf;
+ uint8_t *uncompressedBuf;
{
static std::mutex mu;
std::lock_guard<std::mutex> lock(mu);
- uncompressedBuf = bAlloc().Allocate<char>(size);
+ uncompressedBuf = bAlloc().Allocate<uint8_t>(size);
}
- if (Error e = zlib::uncompress(toStringRef(rawData), uncompressedBuf, size))
+ if (Error e = compression::zlib::uncompress(rawData, uncompressedBuf, size))
fatal(toString(this) +
": uncompress failed: " + llvm::toString(std::move(e)));
- rawData = makeArrayRef((uint8_t *)uncompressedBuf, size);
+ rawData = makeArrayRef(uncompressedBuf, size);
uncompressedSize = -1;
}
@@ -211,8 +207,13 @@ template <typename ELFT> void InputSectionBase::parseCompressedHeader() {
}
auto *hdr = reinterpret_cast<const typename ELFT::Chdr *>(rawData.data());
- if (hdr->ch_type != ELFCOMPRESS_ZLIB) {
- error(toString(this) + ": unsupported compression type");
+ if (hdr->ch_type == ELFCOMPRESS_ZLIB) {
+ if (!compression::zlib::isAvailable())
+ error(toString(this) + " is compressed with ELFCOMPRESS_ZLIB, but lld is "
+ "not built with zlib support");
+ } else {
+ error(toString(this) + ": unsupported compression type (" +
+ Twine(hdr->ch_type) + ")");
return;
}
@@ -622,6 +623,8 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile *file, RelType type,
return sym.getVA(a);
case R_ADDEND:
return a;
+ case R_RELAX_HINT:
+ return 0;
case R_ARM_SBREL:
return sym.getVA(a) - getARMStaticBase(sym);
case R_GOT:
@@ -987,6 +990,8 @@ void InputSectionBase::relocateAlloc(uint8_t *buf, uint8_t *bufEnd) {
*rel.sym, rel.expr),
bits);
switch (rel.expr) {
+ case R_RELAX_HINT:
+ continue;
case R_RELAX_GOT_PC:
case R_RELAX_GOT_PC_NOPIC:
target.relaxGot(bufLoc, rel, targetVA);
@@ -1213,7 +1218,7 @@ template <class ELFT> void InputSection::writeTo(uint8_t *buf) {
// to the buffer.
if (uncompressedSize >= 0) {
size_t size = uncompressedSize;
- if (Error e = zlib::uncompress(toStringRef(rawData), (char *)buf, size))
+ if (Error e = compression::zlib::uncompress(rawData, buf, size))
fatal(toString(this) +
": uncompress failed: " + llvm::toString(std::move(e)));
uint8_t *bufEnd = buf + size;