[PATCH] D46420: Object: The default alignment of a section without alignment flags is 16.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 3 20:49:26 PDT 2018
pcc created this revision.
pcc added reviewers: ruiu, hans.
Depends on https://reviews.llvm.org/D46419
https://reviews.llvm.org/D46420
Files:
lld/test/COFF/default-alignment.test
llvm/include/llvm/Object/COFF.h
Index: llvm/include/llvm/Object/COFF.h
===================================================================
--- llvm/include/llvm/Object/COFF.h
+++ llvm/include/llvm/Object/COFF.h
@@ -452,11 +452,12 @@
if (Characteristics & COFF::IMAGE_SCN_TYPE_NO_PAD)
return 1;
- // Bit [20:24] contains section alignment. Both 0 and 1 mean alignment 1.
+ // Bit [20:24] contains section alignment. 0 means use a default alignment
+ // of 16.
uint32_t Shift = (Characteristics >> 20) & 0xF;
if (Shift > 0)
return 1U << (Shift - 1);
- return 1;
+ return 16;
}
};
Index: lld/test/COFF/default-alignment.test
===================================================================
--- /dev/null
+++ lld/test/COFF/default-alignment.test
@@ -0,0 +1,21 @@
+# RUN: yaml2obj < %s > %t.obj
+# RUN: lld-link /out:%t.exe %t.obj /entry:__ImageBase /subsystem:console
+# RUN: llvm-objdump -s %t.exe | FileCheck %s
+
+# CHECK: Contents of section .rdata:
+# CHECK-NEXT: 01000000 00000000 00000000 00000000
+# CHECK-NEXT: 02
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: []
+sections:
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ SectionData: 01
+ - Name: .rdata
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ SectionData: 02
+symbols:
+...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46420.145143.patch
Type: text/x-patch
Size: 1420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180504/dfd9d3bf/attachment.bin>
More information about the llvm-commits
mailing list