[lld] 04eec6f - [lld-macho][nfc] Move list of section names into InputSection.h

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 13 14:41:58 PST 2021


Author: Jez Ng
Date: 2021-03-13T17:41:50-05:00
New Revision: 04eec6f8815fba5c95826e5c5ffb2246c021dbc8

URL: https://github.com/llvm/llvm-project/commit/04eec6f8815fba5c95826e5c5ffb2246c021dbc8
DIFF: https://github.com/llvm/llvm-project/commit/04eec6f8815fba5c95826e5c5ffb2246c021dbc8.diff

LOG: [lld-macho][nfc] Move list of section names into InputSection.h

They were previously in SyntheticSections.h, but now there are
a bunch of non-synthetic section names in the list.

Also renamed `__functionStarts` to `__func_starts` for uniformity with
other section names + keeps the name under 16 characters (in case we ever
want to write it out as a real section).

Reviewed By: #lld-macho, compnerd

Differential Revision: https://reviews.llvm.org/D98586

Added: 
    

Modified: 
    lld/MachO/InputSection.h
    lld/MachO/SyntheticSections.cpp
    lld/MachO/SyntheticSections.h

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
index c83a547b932f..c6324ed2d984 100644
--- a/lld/MachO/InputSection.h
+++ b/lld/MachO/InputSection.h
@@ -76,6 +76,34 @@ bool isCodeSection(InputSection *);
 
 extern std::vector<InputSection *> inputSections;
 
+namespace section_names {
+
+constexpr const char pageZero[] = "__pagezero";
+constexpr const char common[] = "__common";
+constexpr const char header[] = "__mach_header";
+constexpr const char rebase[] = "__rebase";
+constexpr const char binding[] = "__binding";
+constexpr const char weakBinding[] = "__weak_binding";
+constexpr const char lazyBinding[] = "__lazy_binding";
+constexpr const char export_[] = "__export";
+constexpr const char functionStarts[] = "__func_starts";
+constexpr const char symbolTable[] = "__symbol_table";
+constexpr const char indirectSymbolTable[] = "__ind_sym_tab";
+constexpr const char stringTable[] = "__string_table";
+constexpr const char codeSignature[] = "__code_signature";
+constexpr const char got[] = "__got";
+constexpr const char threadPtrs[] = "__thread_ptrs";
+constexpr const char unwindInfo[] = "__unwind_info";
+constexpr const char compactUnwind[] = "__compact_unwind";
+constexpr const char ehFrame[] = "__eh_frame";
+constexpr const char text[] = "__text";
+constexpr const char stubs[] = "__stubs";
+constexpr const char stubHelper[] = "__stub_helper";
+constexpr const char laSymbolPtr[] = "__la_symbol_ptr";
+constexpr const char data[] = "__data";
+
+} // namespace section_names
+
 } // namespace macho
 
 std::string toString(const macho::InputSection *);

diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 66dbfd347a6d..ffab1f3d4466 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -597,8 +597,7 @@ void ExportSection::finalizeContents() {
 void ExportSection::writeTo(uint8_t *buf) const { trieBuilder.writeTo(buf); }
 
 FunctionStartsSection::FunctionStartsSection()
-    : LinkEditSection(segment_names::linkEdit, section_names::functionStarts_) {
-}
+    : LinkEditSection(segment_names::linkEdit, section_names::functionStarts) {}
 
 void FunctionStartsSection::finalizeContents() {
   raw_svector_ostream os{contents};

diff  --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h
index eb0a473ff986..8a100fdbfb8c 100644
--- a/lld/MachO/SyntheticSections.h
+++ b/lld/MachO/SyntheticSections.h
@@ -28,36 +28,6 @@ class DWARFUnit;
 namespace lld {
 namespace macho {
 
-namespace section_names {
-
-constexpr const char pageZero[] = "__pagezero";
-constexpr const char common[] = "__common";
-constexpr const char header[] = "__mach_header";
-constexpr const char rebase[] = "__rebase";
-constexpr const char binding[] = "__binding";
-constexpr const char weakBinding[] = "__weak_binding";
-constexpr const char lazyBinding[] = "__lazy_binding";
-constexpr const char export_[] = "__export";
-constexpr const char functionStarts_[] = "__functionStarts";
-constexpr const char symbolTable[] = "__symbol_table";
-constexpr const char indirectSymbolTable[] = "__ind_sym_tab";
-constexpr const char stringTable[] = "__string_table";
-constexpr const char codeSignature[] = "__code_signature";
-constexpr const char got[] = "__got";
-constexpr const char threadPtrs[] = "__thread_ptrs";
-constexpr const char unwindInfo[] = "__unwind_info";
-// these are not synthetic, but in service of synthetic __unwind_info
-constexpr const char compactUnwind[] = "__compact_unwind";
-constexpr const char ehFrame[] = "__eh_frame";
-// these are not synthetic, but need to be sorted
-constexpr const char text[] = "__text";
-constexpr const char stubs[] = "__stubs";
-constexpr const char stubHelper[] = "__stub_helper";
-constexpr const char laSymbolPtr[] = "__la_symbol_ptr";
-constexpr const char data[] = "__data";
-
-} // namespace section_names
-
 class Defined;
 class DylibSymbol;
 class LoadCommand;


        


More information about the llvm-commits mailing list