[PATCH] D23447: [ELF] - Do not use mergeable sections when LS is used.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 13:04:55 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278555: [ELF] - Do not use mergeable sections when LS is used. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D23447?vs=67825&id=67886#toc
Repository:
rL LLVM
https://reviews.llvm.org/D23447
Files:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/test/ELF/linkerscript/linkerscript-merge-sections.s
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -11,6 +11,7 @@
#include "Driver.h"
#include "Error.h"
#include "InputSection.h"
+#include "LinkerScript.h"
#include "SymbolTable.h"
#include "Symbols.h"
#include "llvm/ADT/STLExtras.h"
@@ -162,6 +163,14 @@
if (Config->Optimize == 0)
return false;
+ // We don't merge if linker script has SECTIONS command. When script
+ // do layout it can merge several sections with different attributes
+ // into single output sections. We currently do not support adding
+ // mergeable input sections to regular output ones as well as adding
+ // regular input sections to mergeable output.
+ if (ScriptConfig->HasContents)
+ return false;
+
// A mergeable section with size 0 is useless because they don't have
// any data to merge. A mergeable string section with size 0 can be
// argued as invalid because it doesn't end with a null character.
Index: lld/trunk/test/ELF/linkerscript/linkerscript-merge-sections.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-merge-sections.s
+++ lld/trunk/test/ELF/linkerscript/linkerscript-merge-sections.s
@@ -0,0 +1,28 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS { .foo : { *(.foo.*) } }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -s %t1 | FileCheck %s
+# CHECK: Contents of section .foo:
+# CHECK-NEXT: 0158 01000000 02000000 00000000 73686f72 ............shor
+# CHECK-NEXT: 0168 7420756e 7369676e 65642069 6e7400 t unsigned int.
+
+.global _start
+_start:
+ nop
+
+.section .foo.1, "aw"
+writable:
+ .long 1
+
+.section .foo.2, "aM", at progbits,1
+readable:
+ .long 2
+
+.section .foo.3, "awx"
+ .long 0
+
+.section .foo.4, "MS", at progbits,1
+.LASF2:
+ .string "short unsigned int"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23447.67886.patch
Type: text/x-patch
Size: 2003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160812/ae860a43/attachment.bin>
More information about the llvm-commits
mailing list