[llvm-commits] [lld] r164976 - in /lld/trunk: lib/ReaderWriter/ELF/ReaderELF.cpp test/elf/Inputs/rodata-test.hexagon test/elf/Inputs/rodata-test.i386 test/elf/check.objtxt test/elf/rodata.objtxt test/elf/sections.objtxt tools/lld-core/lld-core.cpp
Sid Manning
sidneym at codeaurora.org
Mon Oct 1 16:23:05 PDT 2012
Author: sidneym
Date: Mon Oct 1 18:23:05 2012
New Revision: 164976
URL: http://llvm.org/viewvc/llvm-project?rev=164976&view=rev
Log:
This change:
* Updates ReaderELF.cpp contentType method to match ELF.h's logic and now handle
typeData
* Add -arch to ldd-core testdriver
* Add testcase to check typeData
* Update others to stay in sync with this change.
Added:
lld/trunk/test/elf/Inputs/rodata-test.hexagon (with props)
lld/trunk/test/elf/Inputs/rodata-test.i386 (with props)
lld/trunk/test/elf/rodata.objtxt
Modified:
lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp
lld/trunk/test/elf/check.objtxt
lld/trunk/test/elf/sections.objtxt
lld/trunk/tools/lld-core/lld-core.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp?rev=164976&r1=164975&r2=164976&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ReaderELF.cpp Mon Oct 1 18:23:05 2012
@@ -278,17 +278,37 @@
virtual ContentType contentType() const {
- if (_symbol->getType() == llvm::ELF::STT_FUNC)
- return typeCode;
+ ContentType ret = typeUnknown;
- if ((_symbol->getType() == llvm::ELF::STT_COMMON)
- || _symbol->st_shndx == llvm::ELF::SHN_COMMON)
- return typeZeroFill;
-
- if (_symbol->getType() == llvm::ELF::STT_OBJECT)
- return typeData;
- return typeUnknown;
+ switch (_section->sh_type) {
+ case llvm::ELF::SHT_PROGBITS:
+ case llvm::ELF::SHT_DYNAMIC:
+ switch (_section->sh_flags) {
+ case (llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR):
+ ret = typeCode;
+ break;
+ case (llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE):
+ ret = typeData;
+ break;
+ case llvm::ELF::SHF_ALLOC:
+ case (llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_MERGE):
+ case (llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_MERGE |
+ llvm::ELF::SHF_STRINGS):
+ ret = typeConstant;
+ break;
+ }
+ break;
+ case llvm::ELF::SHT_NOBITS:
+ ret = typeZeroFill;
+ break;
+ case llvm::ELF::SHT_NULL:
+ if ((_symbol->getType() == llvm::ELF::STT_COMMON)
+ || _symbol->st_shndx == llvm::ELF::SHN_COMMON)
+ ret = typeZeroFill;
+ break;
+ }
+ return ret;
}
virtual Alignment alignment() const {
Added: lld/trunk/test/elf/Inputs/rodata-test.hexagon
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/rodata-test.hexagon?rev=164976&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/elf/Inputs/rodata-test.hexagon
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: lld/trunk/test/elf/Inputs/rodata-test.i386
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/rodata-test.i386?rev=164976&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/elf/Inputs/rodata-test.i386
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: lld/trunk/test/elf/check.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/check.objtxt?rev=164976&r1=164975&r2=164976&view=diff
==============================================================================
--- lld/trunk/test/elf/check.objtxt (original)
+++ lld/trunk/test/elf/check.objtxt Mon Oct 1 18:23:05 2012
@@ -1,5 +1,5 @@
RUN: lld-core -reader ELF %p/Inputs/object-test.elf-i386 | FileCheck %s -check-prefix ELF-i386
-RUN: lld-core -reader ELF %p/Inputs/object-test.elf-hexagon | FileCheck %s -check-prefix ELF-hexagon
+RUN: lld-core -arch hexagon -reader ELF %p/Inputs/object-test.elf-hexagon | FileCheck %s -check-prefix ELF-hexagon
ELF-i386:atoms:
ELF-i386: - name: global_func
Added: lld/trunk/test/elf/rodata.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/rodata.objtxt?rev=164976&view=auto
==============================================================================
--- lld/trunk/test/elf/rodata.objtxt (added)
+++ lld/trunk/test/elf/rodata.objtxt Mon Oct 1 18:23:05 2012
@@ -0,0 +1,7 @@
+RUN: lld-core -reader ELF -writer ELF -o %t1 %p/Inputs/rodata-test.i386 | llvm-objdump -section-headers %t1 | FileCheck -check-prefix=i386 %s
+RUN: lld-core -arch hexagon -reader ELF -writer ELF -o %t2 %p/Inputs/rodata-test.hexagon | llvm-objdump -section-headers %t2 | FileCheck -check-prefix=hexagon %s
+
+ i386: 4 .rodata 000000004
+
+ hexagon: 5 .rodata 000000004
+
Modified: lld/trunk/test/elf/sections.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/sections.objtxt?rev=164976&r1=164975&r2=164976&view=diff
==============================================================================
--- lld/trunk/test/elf/sections.objtxt (original)
+++ lld/trunk/test/elf/sections.objtxt Mon Oct 1 18:23:05 2012
@@ -2,13 +2,14 @@
RUN: llvm-readobj %t1 | FileCheck -check-prefix=READOBJ %s
RUN: elf-dump --dump-section %t1 | FileCheck -check-prefix=ED %s
-OBJDUMP: 0 000000000 00000000000000000
-OBJDUMP: 1 .text 00000000a 0000000000000014c TEXT DATA
-OBJDUMP: 2 .data 000000004 00000000000000158 DATA
-OBJDUMP: 3 .special 000000004 0000000000000015c DATA
-OBJDUMP: 4 .anotherspecial 000000004 00000000000000160 DATA
-OBJDUMP: 5 .bss 000000000 00000000000000164 BSS
-OBJDUMP: 6 .shstrtab 000000035 00000000000000164
+OBJDUMP: 0 000000000 00000000000000000
+OBJDUMP: 1 .text 00000000a 00000000000000174 TEXT DATA
+OBJDUMP: 2 .data 000000004 00000000000000180 DATA
+OBJDUMP: 3 .bss 000000000 00000000000000184 BSS
+OBJDUMP: 4 .special 000000004 00000000000000184 DATA
+OBJDUMP: 5 .anotherspecial 000000004 00000000000000188 DATA
+OBJDUMP: 6 000000000 0000000000000018c BSS
+OBJDUMP: 7 .shstrtab 000000036 0000000000000018c
READOBJ: File Format : ELF32-i386
READOBJ: Arch : i386
Modified: lld/trunk/tools/lld-core/lld-core.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/lld-core.cpp?rev=164976&r1=164975&r2=164976&view=diff
==============================================================================
--- lld/trunk/tools/lld-core/lld-core.cpp (original)
+++ lld/trunk/tools/lld-core/lld-core.cpp Mon Oct 1 18:23:05 2012
@@ -114,7 +114,23 @@
clEnumValN(readerELF, "ELF", "read as linux would"),
clEnumValEnd));
-
+enum ArchChoice {
+ i386 = llvm::ELF::EM_386,
+ x86_64 = llvm::ELF::EM_X86_64,
+ hexagon = llvm::ELF::EM_HEXAGON
+};
+llvm::cl::opt<ArchChoice>
+archSelected("arch",
+ llvm::cl::desc("Select architecture, only valid with ELF output"),
+ llvm::cl::values(
+ clEnumValN(i386, "i386",
+ "output i386, EM_386 file"),
+ clEnumValN(x86_64,
+ "x86_64", "output x86_64, EM_X86_64 file"),
+ clEnumValN(hexagon,
+ "hexagon", "output Hexagon, EM_HEXAGON file"),
+ clEnumValEnd));
+
class TestingResolverOptions : public ResolverOptions {
public:
@@ -146,12 +162,18 @@
if (cmdLineOutputFilePath.empty())
cmdLineOutputFilePath.assign("-");
- // create writer for final output
+ // create writer for final output, default to i386 if none selected
+ WriterOptionsELF writerOptionsELF(false, llvm::support::little,
+ llvm::ELF::ET_EXEC,
+ archSelected.getValue() == 0
+ ? i386
+ : archSelected);
+
TestingWriterOptionsYAML writerOptionsYAML(cmdLineDoStubsPass,
cmdLineDoGotPass);
WriterOptionsMachO writerOptionsMachO;
WriterOptionsPECOFF writerOptionsPECOFF;
- WriterOptionsELF writerOptionsELF;
+
Writer* writer = nullptr;
switch ( writeSelected ) {
case writeYAML:
More information about the llvm-commits
mailing list