We were mishandling the case where both `__tbss` and `__thread_data` sections were present. TLVP relocations should be encoded as offsets from the start of `__thread_data`, even if the symbol is actually located in `__thread_bss`. Previously, we were writing the offset from the start of the containing section, which doesn't really make sense since there's no way `tlv_get_addr()` can know which section a given `tlv$init` symbol is in at runtime. In addition, this patch ensures that we place `__thread_data` immediately before `__thread_bss`. This is what ld64 does, likely for performance reasons. Zerofill sections must also be at the end of their segments; we were already doing this, but now we ensure that `__thread_bss` occurs before `__bss`, so that it's always possible to have it contiguous with `__thread_data`. Fixes llvm.org/PR48657. Reviewed By: #lld-macho, thakis Differential Revision: https://reviews.llvm.org/D94329
36 lines
804 B
C++
36 lines
804 B
C++
//===- Writer.h -------------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLD_MACHO_WRITER_H
|
|
#define LLD_MACHO_WRITER_H
|
|
|
|
#include <cstdint>
|
|
|
|
namespace lld {
|
|
namespace macho {
|
|
|
|
class OutputSection;
|
|
|
|
class LoadCommand {
|
|
public:
|
|
virtual ~LoadCommand() = default;
|
|
virtual uint32_t getSize() const = 0;
|
|
virtual void writeTo(uint8_t *buf) const = 0;
|
|
};
|
|
|
|
void writeResult();
|
|
|
|
void createSyntheticSections();
|
|
|
|
extern OutputSection *firstTLVDataSection;
|
|
|
|
} // namespace macho
|
|
} // namespace lld
|
|
|
|
#endif
|