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

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 13 09:43:43 PST 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98586

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


Index: lld/MachO/SyntheticSections.h
===================================================================
--- lld/MachO/SyntheticSections.h
+++ lld/MachO/SyntheticSections.h
@@ -28,36 +28,6 @@
 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;
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -597,8 +597,7 @@
 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};
Index: lld/MachO/InputSection.h
===================================================================
--- lld/MachO/InputSection.h
+++ lld/MachO/InputSection.h
@@ -76,6 +76,34 @@
 
 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 *);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98586.330458.patch
Type: text/x-patch
Size: 3786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210313/661603f4/attachment.bin>


More information about the llvm-commits mailing list