[PATCH 1/3] objtool: Write .orc_lookup section header

From: Huaixin Chang
Date: Fri Aug 07 2020 - 00:18:35 EST


The purpose of this patch is to set sh_type to SHT_PROGBITS and remove
write bits away from sh_flags. In order to write section header, just
call elf_create_section() upon section orc_lookup with 0 entry written.

Originally, section headers are as follows:

[23] .orc_unwind_ip PROGBITS ffffffff8259f4b8 0179f4b8
0000000000178bbc 0000000000000000 A 0 0 1
[24] .rela.orc_unwind_ RELA 0000000000000000 11e57b58
00000000008d4668 0000000000000018 I 70 23 8
[25] .orc_unwind PROGBITS ffffffff82718074 01918074
000000000023519a 0000000000000000 A 0 0 1
[26] .orc_lookup NOBITS ffffffff8294d210 01b4d20e
0000000000030038 0000000000000000 WA 0 0 1
[27] .vvar PROGBITS ffffffff8297e000 01b7e000
0000000000001000 0000000000000000 WA 0 0 16

Now, they are changed to:

[23] .orc_unwind_ip PROGBITS ffffffff8259f4b8 0179f4b8
0000000000178bbc 0000000000000000 A 0 0 1
[24] .rela.orc_unwind_ RELA 0000000000000000 11e57b58
00000000008d4668 0000000000000018 I 70 23 8
[25] .orc_unwind PROGBITS ffffffff82718074 01918074
000000000023519a 0000000000000000 A 0 0 1
[26] .orc_lookup PROGBITS ffffffff8294d210 01b4d210
0000000000030038 0000000000000000 A 0 0 1
[27] .vvar PROGBITS ffffffff8297e000 01b7e000
0000000000001000 0000000000000000 WA 0 0 16

Signed-off-by: Huaixin Chang <changhuaixin@xxxxxxxxxxxxxxxxx>
---
tools/objtool/orc_gen.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index 968f55e6dd94..2b2653979ad6 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -189,6 +189,10 @@ int create_orc_sections(struct objtool_file *file)
u_sec = elf_create_section(file->elf, ".orc_unwind",
sizeof(struct orc_entry), idx);

+ /* make flags of section orc_lookup right */
+ if (!elf_create_section(file->elf, ".orc_lookup", sizeof(int), 0))
+ return -1;
+
/* populate sections */
idx = 0;
for_each_sec(file, sec) {
--
2.14.4.44.g2045bb6