Skip to content

Commit e81f5f9

Browse files
committed
Revert r356129 due to greendragon bot failures
llvm-svn: 356133
1 parent 4c4ff13 commit e81f5f9

File tree

8 files changed

+21
-112
lines changed

8 files changed

+21
-112
lines changed

llvm/test/tools/llvm-objcopy/ELF/remove-section-in-segment.test

Lines changed: 0 additions & 47 deletions
This file was deleted.

llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
# RUN: yaml2obj %s > %t
2+
# RUN: cp %t %t1
23
# RUN: llvm-objcopy --strip-all-gnu %t %t2
34
# RUN: llvm-strip --strip-all-gnu %t -o %t3
45
# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s
56
# RUN: cmp %t2 %t3
67

7-
# Show that the debug section in a segment was removed, to match GNU.
8-
# First validate that the offset in use is correct.
9-
# RUN: llvm-objcopy %t %t4
10-
# RUN: od %t4 -t x1 -N 4 -j 120 | FileCheck %s --check-prefix=COPY-BYTES
11-
# RUN: od %t2 -t x1 -N 4 -j 120 | FileCheck %s --check-prefix=STRIP-BYTES
12-
138
!ELF
149
FileHeader:
1510
Class: ELFCLASS64
1611
Data: ELFDATA2LSB
1712
Type: ET_REL
1813
Machine: EM_X86_64
1914
Sections:
20-
- Name: .debug_in_segment
21-
Type: SHT_PROGBITS
22-
Flags: [ ]
23-
Content: "deadbeef"
2415
- Name: .dynstr
2516
Type: SHT_STRTAB
2617
Flags: [ SHF_ALLOC ]
@@ -54,11 +45,6 @@ Sections:
5445
- Name: .rela.text
5546
Type: SHT_RELA
5647
Info: .text
57-
ProgramHeaders:
58-
# Use an arbitrary segment type to show that the segment type is unimportant.
59-
- Type: 0x61234567
60-
Sections:
61-
- Section: .debug_in_segment
6248

6349
# CHECK: SectionHeaderCount: 8
6450

@@ -69,6 +55,3 @@ ProgramHeaders:
6955
# CHECK: Name: .comment
7056
# CHECK: Name: .random_section_name
7157
# CHECK: Name: .shstrtab
72-
73-
# COPY-BYTES: de ad be ef
74-
# STRIP-BYTES: 00 00 00 00

llvm/test/tools/llvm-objcopy/ELF/strip-all.test

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ FileHeader:
5757
Type: ET_REL
5858
Machine: EM_X86_64
5959
Sections:
60-
- Name: non_alloc_in_segment
61-
Type: SHT_PROGBITS
62-
Flags: [ ]
63-
Size: 4
6460
- Name: .bss
6561
Type: SHT_NOBITS
6662
Flags: [ SHF_ALLOC ]
@@ -72,15 +68,9 @@ Sections:
7268
Flags: [ ]
7369
- Name: .gnu.warning.foo
7470
Type: SHT_PROGBITS
75-
ProgramHeaders:
76-
# Use an arbitrary segment type to show that the segment type is unimportant.
77-
- Type: 0x61234567
78-
Sections:
79-
- Section: non_alloc_in_segment
8071

81-
# CHECK: SectionHeaderCount: 6
72+
# CHECK: SectionHeaderCount: 5
8273

83-
# CHECK: Name: non_alloc_in_segment
8474
# CHECK: Name: .bss
8575
# CHECK: Name: .text
8676
# CHECK: Name: .gnu.warning.foo

llvm/test/tools/llvm-objcopy/ELF/strip-non-alloc.test

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ FileHeader:
99
Type: ET_REL
1010
Machine: EM_X86_64
1111
Sections:
12-
- Name: non_alloc_in_segment
13-
Type: SHT_PROGBITS
14-
Flags: [ ]
15-
Size: 4
1612
- Name: .bss
1713
Type: SHT_NOBITS
1814
Flags: [ SHF_ALLOC ]
@@ -22,15 +18,9 @@ Sections:
2218
- Name: .blarg
2319
Type: SHT_PROGBITS
2420
Flags: [ ]
25-
ProgramHeaders:
26-
# Use an arbitrary segment type to show that the segment type is unimportant.
27-
- Type: 0x61234567
28-
Sections:
29-
- Section: non_alloc_in_segment
3021

31-
# CHECK: SectionHeaderCount: 5
22+
# CHECK: SectionHeaderCount: 4
3223

33-
# CHECK: Name: non_alloc_in_segment
3424
# CHECK: Name: .bss
3525
# CHECK: Name: .text
3626
# CHECK: Name: .shstrtab

llvm/test/tools/llvm-objcopy/ELF/strip-sections.test

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ Sections:
1515
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
1616
AddressAlign: 0x0000000000001000
1717
Content: "DEADBEEF"
18-
- Name: .non_alloc_in_segment
19-
Type: SHT_PROGBITS
20-
Flags: [ ]
21-
Content: "CAFEBABE"
2218
ProgramHeaders:
2319
- Type: PT_LOAD
2420
Flags: [ PF_X, PF_R ]
2521
Sections:
2622
- Section: .text
27-
- Section: .non_alloc_in_segment
2823

29-
#DATA: 0010000 de ad be ef ca fe ba be
24+
#DATA: 0010000 de ad be ef
3025

3126
#CHECK: ElfHeader {
3227
#CHECK-NEXT: Ident {
@@ -60,8 +55,8 @@ ProgramHeaders:
6055
#CHECK-NEXT: Offset: 0x1000
6156
#CHECK-NEXT: VirtualAddress: 0x0
6257
#CHECK-NEXT: PhysicalAddress: 0x0
63-
#CHECK-NEXT: FileSize: 8
64-
#CHECK-NEXT: MemSize: 8
58+
#CHECK-NEXT: FileSize: 4
59+
#CHECK-NEXT: MemSize: 4
6560
#CHECK-NEXT: Flags [ (0x5)
6661
#CHECK-NEXT: PF_R (0x4)
6762
#CHECK-NEXT: PF_X (0x1)

llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
403403

404404
if (Config.StripSections) {
405405
RemovePred = [RemovePred](const SectionBase &Sec) {
406-
return RemovePred(Sec) || Sec.ParentSegment == nullptr;
406+
return RemovePred(Sec) || (Sec.Flags & SHF_ALLOC) == 0;
407407
};
408408
}
409409

@@ -419,7 +419,7 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
419419
return true;
420420
if (&Sec == Obj.SectionNames)
421421
return false;
422-
return (Sec.Flags & SHF_ALLOC) == 0 && Sec.ParentSegment == nullptr;
422+
return (Sec.Flags & SHF_ALLOC) == 0;
423423
};
424424

425425
if (Config.StripAll)
@@ -430,8 +430,6 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
430430
return false;
431431
if (StringRef(Sec.Name).startswith(".gnu.warning"))
432432
return false;
433-
if (Sec.ParentSegment != nullptr)
434-
return false;
435433
return (Sec.Flags & SHF_ALLOC) == 0;
436434
};
437435

llvm/tools/llvm-objcopy/ObjcopyOpts.td

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ defm set_section_flags
103103
"rom, share, contents, merge, strings.">,
104104
MetaVarName<"section=flag1[,flag2,...]">;
105105

106-
def strip_all : Flag<["-", "--"], "strip-all">,
107-
HelpText<"Remove non-allocated sections outside segments. "
108-
".gnu.warning* sections are not removed">;
106+
def strip_all
107+
: Flag<["-", "--"], "strip-all">,
108+
HelpText<
109+
"Remove non-allocated sections other than .gnu.warning* sections">;
109110
def S : Flag<["-"], "S">, Alias<strip_all>;
110111
def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
111112
HelpText<"Compatible with GNU objcopy's --strip-all">;
@@ -115,15 +116,13 @@ def g : Flag<["-"], "g">, Alias<strip_debug>,
115116
HelpText<"Alias for --strip-debug">;
116117
def strip_dwo : Flag<["-", "--"], "strip-dwo">,
117118
HelpText<"Remove all DWARF .dwo sections from file">;
118-
def strip_sections
119-
: Flag<["-", "--"], "strip-sections">,
120-
HelpText<"Remove all section headers and all sections not in segments">;
121-
def strip_non_alloc
122-
: Flag<["-", "--"], "strip-non-alloc">,
123-
HelpText<"Remove all non-allocated sections outside segments">;
119+
def strip_sections : Flag<["-", "--"], "strip-sections">,
120+
HelpText<"Remove all section headers">;
121+
def strip_non_alloc : Flag<["-", "--"], "strip-non-alloc">,
122+
HelpText<"Remove all non-allocated sections">;
124123
def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
125124
HelpText<"Remove all symbols not needed by relocations">;
126-
defm strip_unneeded_symbol
125+
defm strip_unneeded_symbol
127126
: Eq<"strip-unneeded-symbol",
128127
"Remove symbol <symbol> if it is not needed by relocations">,
129128
MetaVarName<"symbol">;

llvm/tools/llvm-objcopy/StripOpts.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ def preserve_dates : Flag<["-", "--"], "preserve-dates">,
3131
HelpText<"Preserve access and modification timestamps">;
3232
def p : Flag<["-"], "p">, Alias<preserve_dates>;
3333

34-
def strip_all : Flag<["-", "--"], "strip-all">,
35-
HelpText<"Remove non-allocated sections outside segments. "
36-
".gnu.warning* sections are not removed">;
34+
def strip_all
35+
: Flag<["-", "--"], "strip-all">,
36+
HelpText<
37+
"Remove non-allocated sections other than .gnu.warning* sections">;
3738
def s : Flag<["-"], "s">, Alias<strip_all>;
3839

3940
def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,

0 commit comments

Comments
 (0)