File tree Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ InStruct macho::in;
47
47
std::vector<SyntheticSection *> macho::syntheticSections;
48
48
49
49
SyntheticSection::SyntheticSection (const char *segname, const char *name)
50
- : OutputSection(SyntheticKind, name), segname(segname) {
50
+ : OutputSection(SyntheticKind, name) {
51
+ std::tie (this ->segname , this ->name ) = maybeRenameSection ({segname, name});
51
52
isec = make<ConcatInputSection>(segname, name);
52
53
isec->parent = this ;
53
54
syntheticSections.push_back (this );
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class SyntheticSection : public OutputSection {
46
46
return sec->kind () == SyntheticKind;
47
47
}
48
48
49
- const StringRef segname;
49
+ StringRef segname;
50
50
// This fake InputSection makes it easier for us to write code that applies
51
51
// generically to both user inputs and synthetics.
52
52
InputSection *isec;
Original file line number Diff line number Diff line change @@ -855,7 +855,7 @@ static void sortSegmentsAndSections() {
855
855
}
856
856
}
857
857
858
- static NamePair maybeRenameSection (NamePair key) {
858
+ NamePair macho:: maybeRenameSection (NamePair key) {
859
859
auto newNames = config->sectionRenameMap .find (key);
860
860
if (newNames != config->sectionRenameMap .end ())
861
861
return newNames->second ;
Original file line number Diff line number Diff line change 9
9
#ifndef LLD_MACHO_WRITER_H
10
10
#define LLD_MACHO_WRITER_H
11
11
12
+ #include " Config.h"
13
+
12
14
#include < cstdint>
13
15
14
16
namespace lld {
@@ -27,6 +29,8 @@ class LoadCommand {
27
29
28
30
template <class LP > void writeResult ();
29
31
32
+ NamePair maybeRenameSection (NamePair key);
33
+
30
34
void createSyntheticSections ();
31
35
32
36
// Add bindings for symbols that need weak or non-lazy bindings.
Original file line number Diff line number Diff line change 30
30
# RUN: %lld \
31
31
# RUN: -rename_section __FROM_SECT __from_sect __TO_SECT __to_sect \
32
32
# RUN: -rename_segment __FROM_SEG __TO_SEG \
33
+ # RUN: -rename_section __TEXT __cstring __RODATA __cstring \
33
34
# RUN: -o %t %t.o
34
35
# RUN: llvm-objdump --macho --all-headers %t | FileCheck %s
35
36
36
37
# CHECK: {{^}}Section{{$}}
37
38
# CHECK-NEXT: sectname __text
38
39
# CHECK-NEXT: segname __TEXT
39
40
# CHECK: {{^}}Section{{$}}
40
- # CHECK-NOT: sectname __from_sect
41
41
# CHECK-NEXT: sectname __to_sect
42
- # CHECK-NOT: segname __FROM_SECT
43
42
# CHECK-NEXT: segname __TO_SECT
44
43
# CHECK: {{^}}Section{{$}}
45
44
# CHECK-NEXT: sectname __from_seg
46
- # CHECK-NOT: segname __FROM_SEG
47
45
# CHECK-NEXT: segname __TO_SEG
46
+ # CHECK: {{^}}Section{{$}}
47
+ # CHECK-NEXT: sectname __cstring
48
+ # CHECK-NEXT: segname __RODATA
48
49
49
50
.section __FROM_SECT,__from_sect
50
51
.global _from_sect
@@ -56,6 +57,10 @@ _from_sect:
56
57
_from_seg:
57
58
.space 8
58
59
60
+ ## This is a synthetic section; make sure it gets renamed too.
61
+ .cstring
62
+ .space 8
63
+
59
64
.text
60
65
.global _main
61
66
_main:
You can’t perform that action at this time.
0 commit comments