File tree Expand file tree Collapse file tree 2 files changed +79
-2
lines changed Expand file tree Collapse file tree 2 files changed +79
-2
lines changed Original file line number Diff line number Diff line change @@ -796,8 +796,12 @@ void ELFState<ELFT>::writeSectionContent(
796
796
" Section type is not SHT_REL nor SHT_RELA" );
797
797
798
798
bool IsRela = Section.Type == llvm::ELF::SHT_RELA;
799
- SHeader.sh_entsize = IsRela ? sizeof (Elf_Rela) : sizeof (Elf_Rel);
800
- SHeader.sh_size = SHeader.sh_entsize * Section.Relocations .size ();
799
+ if (Section.EntSize )
800
+ SHeader.sh_entsize = *Section.EntSize ;
801
+ else
802
+ SHeader.sh_entsize = IsRela ? sizeof (Elf_Rela) : sizeof (Elf_Rel);
803
+ SHeader.sh_size = (IsRela ? sizeof (Elf_Rela) : sizeof (Elf_Rel)) *
804
+ Section.Relocations .size ();
801
805
802
806
// For relocation section set link to .symtab by default.
803
807
unsigned Link = 0 ;
Original file line number Diff line number Diff line change
1
+ # # Test how yaml2obj sets values for sh_entsize fields of relocation sections.
2
+
3
+ # RUN: yaml2obj --docnum=1 %s -o %t64
4
+ # RUN: llvm-readelf --sections %t64 | FileCheck %s --check-prefix=ELF64
5
+
6
+ # RUN: yaml2obj --docnum=2 %s -o %t32
7
+ # RUN: llvm-readelf --sections %t32 | FileCheck %s --check-prefix=ELF32
8
+
9
+ # ELF64: Name Type Address Off Size ES
10
+ # ELF64: .rela.default RELA 0000000000000000 000040 000000 18
11
+ # ELF64: .rel.default REL 0000000000000000 000040 000000 10
12
+ # ELF64: .relr.default RELR 0000000000000000 000040 000000 08
13
+ # ELF64: .rela.custom RELA 0000000000000000 000040 000000 ff
14
+ # ELF64: .rel.custom REL 0000000000000000 000040 000000 ff
15
+ # ELF64: .relr.custom RELR 0000000000000000 000040 000000 ff
16
+
17
+ # ELF32: Name Type Address Off Size ES
18
+ # ELF32: .rela.default RELA 00000000 000034 000000 0c
19
+ # ELF32: .rel.default REL 00000000 000034 000000 08
20
+ # ELF32: .relr.default RELR 00000000 000034 000000 04
21
+ # ELF32: .rela.custom RELA 00000000 000034 000000 ff
22
+ # ELF32: .rel.custom REL 00000000 000034 000000 ff
23
+ # ELF32: .relr.custom RELR 00000000 000034 000000 ff
24
+
25
+ --- !ELF
26
+ FileHeader :
27
+ Class : ELFCLASS64
28
+ Data : ELFDATA2LSB
29
+ Type : ET_REL
30
+ Machine : EM_X86_64
31
+ Sections :
32
+ # # Check default sh_entsize field values.
33
+ - Name : .rela.default
34
+ Type : SHT_RELA
35
+ - Name : .rel.default
36
+ Type : SHT_REL
37
+ - Name : .relr.default
38
+ Type : SHT_RELR
39
+ # # Check we can set sh_entsize fields to arbitrary values.
40
+ - Name : .rela.custom
41
+ Type : SHT_RELA
42
+ EntSize : 0xFF
43
+ - Name : .rel.custom
44
+ Type : SHT_REL
45
+ EntSize : 0xFF
46
+ - Name : .relr.custom
47
+ Type : SHT_RELR
48
+ EntSize : 0xFF
49
+
50
+ --- !ELF
51
+ FileHeader :
52
+ Class : ELFCLASS32
53
+ Data : ELFDATA2LSB
54
+ Type : ET_REL
55
+ Machine : EM_386
56
+ Sections :
57
+ # # Check default sh_entsizes field values.
58
+ - Name : .rela.default
59
+ Type : SHT_RELA
60
+ - Name : .rel.default
61
+ Type : SHT_REL
62
+ - Name : .relr.default
63
+ Type : SHT_RELR
64
+ # # Check we can set sh_entsize fields to arbitrary values.
65
+ - Name : .rela.custom
66
+ Type : SHT_RELA
67
+ EntSize : 0xFF
68
+ - Name : .rel.custom
69
+ Type : SHT_REL
70
+ EntSize : 0xFF
71
+ - Name : .relr.custom
72
+ Type : SHT_RELR
73
+ EntSize : 0xFF
You can’t perform that action at this time.
0 commit comments