File tree Expand file tree Collapse file tree 4 files changed +36
-6
lines changed
test/tools/llvm-objcopy/ELF Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ Sections:
21
21
- Offset : 0x2
22
22
Symbol : .notdebug_foo
23
23
Type : R_X86_64_32
24
+ # # This section should not be involved in relocations.
25
+ - Name : .debug_bar
26
+ Type : SHT_PROGBITS
27
+ Content : 0000000000000000
24
28
Symbols :
25
29
Global :
26
30
- Name : .debug_foo
@@ -29,4 +33,6 @@ Symbols:
29
33
- Name : .notdebug_foo
30
34
Type : STT_SECTION
31
35
Section : .notdebug_foo
36
+ - Name : .Linfo_string0
37
+ Section : .debug_bar
32
38
...
Original file line number Diff line number Diff line change
1
+ # REQUIRES: zlib
2
+
3
+ # RUN: yaml2obj %p/Inputs/compress-debug-sections.yaml -o %t.o
4
+
5
+ ## Test that after the compression is done we do not remove the symbol
6
+ ## and it is placed into the right section.
7
+
8
+ # RUN: llvm-objcopy --compress-debug-sections %t.o %t-compressed1.o
9
+ # RUN: llvm-readobj -symbols %t-compressed1.o | FileCheck %s --check-prefixes=CHECK,ZLIB
10
+
11
+ # RUN: llvm-objcopy --compress-debug-sections=zlib-gnu %t.o %t-compressed2.o
12
+ # RUN: llvm-readobj -symbols %t-compressed2.o | FileCheck %s --check-prefixes=CHECK,ZLIBGNU
13
+
14
+ # CHECK: Name: .Linfo_string0
15
+ # CHECK-NEXT: Value: 0x0
16
+ # CHECK-NEXT: Size: 0
17
+ # CHECK-NEXT: Binding: Global
18
+ # CHECK-NEXT: Type: None
19
+ # CHECK-NEXT: Other: 0
20
+ # ZLIB-NEXT: Section: .debug_bar
21
+ # ZLIBGNU-NEXT: Section: .zdebug_bar
Original file line number Diff line number Diff line change @@ -457,6 +457,13 @@ Error SymbolTableSection::removeSymbols(
457
457
return Error::success ();
458
458
}
459
459
460
+ void SymbolTableSection::replaceSectionReferences (
461
+ const DenseMap<SectionBase *, SectionBase *> &FromTo) {
462
+ for (std::unique_ptr<Symbol> &Sym : Symbols)
463
+ if (SectionBase *To = FromTo.lookup (Sym->DefinedIn ))
464
+ Sym->DefinedIn = To;
465
+ }
466
+
460
467
void SymbolTableSection::initialize (SectionTableRef SecTable) {
461
468
Size = 0 ;
462
469
setStrTab (SecTable.getSectionOfType <StringTableSection>(
@@ -638,12 +645,6 @@ void RelocationSection::replaceSectionReferences(
638
645
// Update the target section if it was replaced.
639
646
if (SectionBase *To = FromTo.lookup (SecToApplyRel))
640
647
SecToApplyRel = To;
641
-
642
- // Change the sections where symbols are defined in if their
643
- // original sections were replaced.
644
- for (const Relocation &R : Relocations)
645
- if (SectionBase *To = FromTo.lookup (R.RelocSymbol ->DefinedIn ))
646
- R.RelocSymbol ->DefinedIn = To;
647
648
}
648
649
649
650
void SectionWriter::visit (const DynamicRelocationSection &Sec) {
Original file line number Diff line number Diff line change @@ -529,6 +529,8 @@ class SymbolTableSection : public SectionBase {
529
529
void accept (SectionVisitor &Visitor) const override ;
530
530
void accept (MutableSectionVisitor &Visitor) override ;
531
531
Error removeSymbols (function_ref<bool (const Symbol &)> ToRemove) override ;
532
+ void replaceSectionReferences (
533
+ const DenseMap<SectionBase *, SectionBase *> &FromTo) override ;
532
534
533
535
static bool classof (const SectionBase *S) {
534
536
return S->Type == ELF::SHT_SYMTAB;
You can’t perform that action at this time.
0 commit comments