[PATCH] D30419: [ELF] - Define __bss_start symbol.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 4 05:17:30 PDT 2017
grimar updated this revision to Diff 94054.
grimar added a comment.
- Addressed review comments.
https://reviews.llvm.org/D30419
Files:
ELF/Symbols.cpp
ELF/Symbols.h
ELF/Writer.cpp
test/ELF/bss-start-common.s
Index: test/ELF/bss-start-common.s
===================================================================
--- test/ELF/bss-start-common.s
+++ test/ELF/bss-start-common.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: ld.lld %t -o %t2
+# RUN: llvm-objdump -t -section-headers %t2 | FileCheck %s
+
+# CHECK: Sections:
+# CHECK: Idx Name Size Address Type
+# CHECK: 2 .bss 00000004 0000000000201000 BSS
+# CHECK: SYMBOL TABLE:
+# CHECK: 0000000000201000 .bss 00000000 __bss_start
+
+.global __bss_start
+.text
+_start:
+.comm sym1,4,4
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -846,6 +846,10 @@
// __ehdr_start is the location of ELF file headers.
addOptionalRegular<ELFT>("__ehdr_start", Out::ElfHeader, 0, STV_HIDDEN);
+ // __bss_start is the location of .bss.* sections.
+ ElfSym::Bss =
+ addOptionalRegular<ELFT>("__bss_start", Out::ElfHeader, 0, STV_DEFAULT);
+
auto Define = [](StringRef S, DefinedRegular *&Sym1, DefinedRegular *&Sym2) {
Sym1 = addOptionalRegular<ELFT>(S, Out::ElfHeader, 0, STV_DEFAULT);
assert(S.startswith("_"));
@@ -1675,6 +1679,9 @@
if (LastRW)
Set(ElfSym::Edata, ElfSym::Edata2, LastRW->First, LastRW->p_filesz);
+ if (ElfSym::Bss)
+ ElfSym::Bss->Section = findSection(".bss");
+
// Setup MIPS _gp_disp/__gnu_local_gp symbols which should
// be equal to the _gp symbol's value.
if (Config->EMachine == EM_MIPS) {
Index: ELF/Symbols.h
===================================================================
--- ELF/Symbols.h
+++ ELF/Symbols.h
@@ -302,6 +302,9 @@
// Some linker-generated symbols need to be created as
// DefinedRegular symbols.
struct ElfSym {
+ // The content for __bss_start symbol.
+ static DefinedRegular *Bss;
+
// The content for _etext and etext symbols.
static DefinedRegular *Etext;
static DefinedRegular *Etext2;
Index: ELF/Symbols.cpp
===================================================================
--- ELF/Symbols.cpp
+++ ELF/Symbols.cpp
@@ -28,6 +28,7 @@
using namespace lld;
using namespace lld::elf;
+DefinedRegular *ElfSym::Bss;
DefinedRegular *ElfSym::Etext;
DefinedRegular *ElfSym::Etext2;
DefinedRegular *ElfSym::Edata;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30419.94054.patch
Type: text/x-patch
Size: 2338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170404/07b1fd0a/attachment.bin>
More information about the llvm-commits
mailing list