Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 1859a60

Browse files
committed
[WebAssembly] Group rodata into a single output segment
Differential Revision: https://reviews.llvm.org/D50424 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@339279 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent afe77db commit 1859a60

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

test/wasm/data-segment-merging.ll

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,27 @@ target triple = "wasm32-unknown-unknown"
55
@c = hidden global [9 x i8] c"whatever\00", align 1
66
@d = hidden global i32 42, align 4
77

8+
@e = private constant [9 x i8] c"constant\00", align 1
9+
@f = private constant i8 43, align 4
10+
811
; RUN: llc -filetype=obj %s -o %t.data-segment-merging.o
912

1013
; RUN: wasm-ld -no-gc-sections --no-entry -o %t.merged.wasm %t.data-segment-merging.o
1114
; RUN: obj2yaml %t.merged.wasm | FileCheck %s --check-prefix=MERGE
12-
; MERGE: - Type: DATA
13-
; MERGE-NEXT: Segments:
14-
; MERGE-NEXT: - SectionOffset: 7
15-
; MERGE-NEXT: MemoryIndex: 0
16-
; MERGE-NEXT: Offset:
17-
; MERGE-NEXT: Opcode: I32_CONST
18-
; MERGE-NEXT: Value: 1024
19-
; MERGE-NEXT: Content: 68656C6C6F00676F6F6462796500776861746576657200002A000000
15+
; MERGE: - Type: DATA
16+
; MERGE: Segments:
17+
; MERGE: Content: 68656C6C6F00676F6F6462796500776861746576657200002A000000
18+
; MERGE: Content: 636F6E7374616E74000000002B
19+
; MERGE-NOT: Content:
2020

2121
; RUN: wasm-ld -no-gc-sections --no-entry --no-merge-data-segments -o %t.separate.wasm %t.data-segment-merging.o
2222
; RUN: obj2yaml %t.separate.wasm | FileCheck %s --check-prefix=SEPARATE
23-
; SEPARATE: - Type: DATA
24-
; SEPARATE-NEXT: Segments:
25-
; SEPARATE-NEXT: - SectionOffset: 7
26-
; SEPARATE-NEXT: MemoryIndex: 0
27-
; SEPARATE-NEXT: Offset:
28-
; SEPARATE-NEXT: Opcode: I32_CONST
29-
; SEPARATE-NEXT: Value: 1024
30-
; SEPARATE-NEXT: Content: 68656C6C6F00
31-
; SEPARATE-NEXT: - SectionOffset: 19
32-
; SEPARATE-NEXT: MemoryIndex: 0
33-
; SEPARATE-NEXT: Offset:
34-
; SEPARATE-NEXT: Opcode: I32_CONST
35-
; SEPARATE-NEXT: Value: 1030
36-
; SEPARATE-NEXT: Content: 676F6F6462796500
37-
; SEPARATE-NEXT: - SectionOffset: 33
38-
; SEPARATE-NEXT: MemoryIndex: 0
39-
; SEPARATE-NEXT: Offset:
40-
; SEPARATE-NEXT: Opcode: I32_CONST
41-
; SEPARATE-NEXT: Value: 1038
42-
; SEPARATE-NEXT: Content: '776861746576657200'
43-
; SEPARATE-NEXT: - SectionOffset: 48
44-
; SEPARATE-NEXT: MemoryIndex: 0
45-
; SEPARATE-NEXT: Offset:
46-
; SEPARATE-NEXT: Opcode: I32_CONST
47-
; SEPARATE-NEXT: Value: 1048
48-
; SEPARATE-NEXT: Content: 2A000000
23+
; SEPARATE: - Type: DATA
24+
; SEPARATE: Segments:
25+
; SEPARATE: Content: 68656C6C6F00
26+
; SEPARATE: Content: 676F6F6462796500
27+
; SEPARATE: Content: '776861746576657200'
28+
; SEPARATE: Content: 2A000000
29+
; SEPARATE: Content: 636F6E7374616E7400
30+
; SEPARATE: Content: 2B
31+
; SEPARATE-NOT: Content:

wasm/Writer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,8 @@ static StringRef getOutputDataSegmentName(StringRef Name) {
930930
return ".data";
931931
if (Name.startswith(".bss."))
932932
return ".bss";
933+
if (Name.startswith(".rodata."))
934+
return ".rodata";
933935
return Name;
934936
}
935937

0 commit comments

Comments
 (0)