Skip to content

Commit 8cff174

Browse files
committed
Rollback r246276 - Object: Teach llvm-ar to create symbol table for COFF short import files
This change caused a test for llvm-readobj to fail. llvm-svn: 246277
1 parent 22b1b7a commit 8cff174

File tree

4 files changed

+1
-56
lines changed

4 files changed

+1
-56
lines changed

llvm/lib/Object/SymbolicFile.cpp

+1-46
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,14 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "llvm/Object/COFF.h"
1514
#include "llvm/Object/IRObjectFile.h"
1615
#include "llvm/Object/ObjectFile.h"
1716
#include "llvm/Object/SymbolicFile.h"
18-
#include "llvm/Support/COFF.h"
1917
#include "llvm/Support/MemoryBuffer.h"
2018

2119
using namespace llvm;
2220
using namespace object;
2321

24-
// COFF short import file is a special kind of file which contains
25-
// only symbol names for DLL-exported symbols. This class implements
26-
// SymbolicFile interface for the file.
27-
namespace {
28-
class COFFImportFile : public SymbolicFile {
29-
public:
30-
COFFImportFile(MemoryBufferRef Source)
31-
: SymbolicFile(sys::fs::file_magic::coff_import_library, Source) {}
32-
33-
void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
34-
35-
std::error_code printSymbolName(raw_ostream &OS,
36-
DataRefImpl Symb) const override {
37-
if (Symb.p == 1)
38-
OS << "__imp_";
39-
OS << StringRef(Data.getBufferStart() + sizeof(coff_import_header));
40-
return std::error_code();
41-
}
42-
43-
uint32_t getSymbolFlags(DataRefImpl Symb) const override {
44-
return SymbolRef::SF_Global;
45-
}
46-
47-
basic_symbol_iterator symbol_begin_impl() const override {
48-
return BasicSymbolRef(DataRefImpl(), this);
49-
}
50-
51-
basic_symbol_iterator symbol_end_impl() const override {
52-
DataRefImpl Symb;
53-
Symb.p = isCode() ? 2 : 1;
54-
return BasicSymbolRef(Symb, this);
55-
}
56-
57-
private:
58-
bool isCode() const {
59-
auto *Import = reinterpret_cast<const coff_import_header *>(
60-
Data.getBufferStart());
61-
return Import->getType() == llvm::COFF::IMPORT_CODE;
62-
}
63-
};
64-
} // anonymous namespace
65-
6622
SymbolicFile::SymbolicFile(unsigned int Type, MemoryBufferRef Source)
6723
: Binary(Type, Source) {}
6824

@@ -98,10 +54,9 @@ ErrorOr<std::unique_ptr<SymbolicFile>> SymbolicFile::createSymbolicFile(
9854
case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub:
9955
case sys::fs::file_magic::macho_dsym_companion:
10056
case sys::fs::file_magic::macho_kext_bundle:
57+
case sys::fs::file_magic::coff_import_library:
10158
case sys::fs::file_magic::pecoff_executable:
10259
return ObjectFile::createObjectFile(Object, Type);
103-
case sys::fs::file_magic::coff_import_library:
104-
return std::unique_ptr<SymbolicFile>(new COFFImportFile(Object));
10560
case sys::fs::file_magic::elf_relocatable:
10661
case sys::fs::file_magic::macho_object:
10762
case sys::fs::file_magic::coff_object: {
-31 Bytes
Binary file not shown.
-31 Bytes
Binary file not shown.

llvm/test/Object/archive-symtab.test

-10
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ MACHO-NEXT: 0000000000000000 t _bar
9999
MACHO-NEXT: 0000000000000001 T _foo
100100
MACHO-NEXT: 0000000000000002 T _main
101101

102-
RUN: rm -f %t.a
103-
RUN: llvm-ar --format=gnu rcsU %t.a %p/Inputs/coff-short-import-code %p/Inputs/coff-short-import-data
104-
RUN: llvm-nm -M %t.a | FileCheck --check-prefix=COFF-SHORT-IMPORT %s
105-
106-
COFF-SHORT-IMPORT: Archive map
107-
COFF-SHORT-IMPORT-NEXT: _foo in coff-short-import-code
108-
COFF-SHORT-IMPORT-NEXT: __imp__foo in coff-short-import-code
109-
COFF-SHORT-IMPORT-NEXT: _bar in coff-short-import-data
110-
COFF-SHORT-IMPORT-NOT: __imp__bar in coff-short-import-data
111-
112102
Test that we pad the symbol table so that it ends in a multiple of 4 bytes:
113103
8 + 60 + 36 == 104
114104
RUN: rm -f %t.a

0 commit comments

Comments
 (0)