diff mbox series

[1/3] scripts/sorttable: Change section type of orc_lookup to SHT_PROGBITS

Message ID 20200723034643.33537-2-changhuaixin@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series Build ORC fast lookup table in scripts/sorttable tool | expand

Commit Message

changhuaixin July 23, 2020, 3:46 a.m. UTC
In order to edit orc_lookup table via sorttable, type of section
orc_lookup needs to be SHT_PROGBITS instead of SHT_NOBITS.

Linker script doesn't seem to allow manual specification of the section
type, so just write a byte into the section instead.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Huaixin Chang <changhuaixin@linux.alibaba.com>
Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
---
 include/asm-generic/vmlinux.lds.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ingo Molnar July 24, 2020, 1:55 p.m. UTC | #1
* Huaixin Chang <changhuaixin@linux.alibaba.com> wrote:

> In order to edit orc_lookup table via sorttable, type of section
> orc_lookup needs to be SHT_PROGBITS instead of SHT_NOBITS.
> 
> Linker script doesn't seem to allow manual specification of the section
> type, so just write a byte into the section instead.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> Signed-off-by: Huaixin Chang <changhuaixin@linux.alibaba.com>
> Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
> ---
>  include/asm-generic/vmlinux.lds.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index db600ef218d7..49f4f5bc6165 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -826,6 +826,8 @@
>  		. += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) /	\
>  			LOOKUP_BLOCK_SIZE) + 1) * 4;			\
>  		orc_lookup_end = .;					\
> +		/* HACK: force SHT_PROGBITS so sorttable can edit: */	\
> +		BYTE(1);						\

Cc:-ing Masahiro Yamada, maybe there's a cleaner solution to this?

Thanks,

	Ingo
changhuaixin Aug. 4, 2020, 1:40 a.m. UTC | #2
Hi, Ingo

Another way to write SHT_PROGBITS is using elf_create_section to write orc_lookup table headers, when orc_unwind_ip table and orc_unwind table are written. Is this a better solution?

diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index 3f98dcfbc177..860d4dcec8e6 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -183,6 +183,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) {

Thanks,
Huaixin

> On Jul 23, 2020, at 11:46 AM, Huaixin Chang <changhuaixin@linux.alibaba.com> wrote:
> 
> In order to edit orc_lookup table via sorttable, type of section
> orc_lookup needs to be SHT_PROGBITS instead of SHT_NOBITS.
> 
> Linker script doesn't seem to allow manual specification of the section
> type, so just write a byte into the section instead.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> Signed-off-by: Huaixin Chang <changhuaixin@linux.alibaba.com>
> Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
> ---
> include/asm-generic/vmlinux.lds.h | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index db600ef218d7..49f4f5bc6165 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -826,6 +826,8 @@
> 		. += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) /	\
> 			LOOKUP_BLOCK_SIZE) + 1) * 4;			\
> 		orc_lookup_end = .;					\
> +		/* HACK: force SHT_PROGBITS so sorttable can edit: */	\
> +		BYTE(1);						\
> 	}
> #else
> #define ORC_UNWIND_TABLE
> -- 
> 2.14.4.44.g2045bb6
Ingo Molnar Aug. 6, 2020, 3:08 p.m. UTC | #3
* changhuaixin <changhuaixin@linux.alibaba.com> wrote:

> Hi, Ingo
> 
> Another way to write SHT_PROGBITS is using elf_create_section to write orc_lookup table headers, when orc_unwind_ip table and orc_unwind table are written. Is this a better solution?
> 
> diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> index 3f98dcfbc177..860d4dcec8e6 100644
> --- a/tools/objtool/orc_gen.c
> +++ b/tools/objtool/orc_gen.c
> @@ -183,6 +183,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) {

Looks much nicer IMO.

Mind turning this into a proper patch that does it plus reverts the 
hack?

Thanks,

	Ingo
changhuaixin Aug. 7, 2020, 4:22 a.m. UTC | #4
> On Aug 6, 2020, at 11:08 PM, Ingo Molnar <mingo@kernel.org> wrote:
> 
> 
> * changhuaixin <changhuaixin@linux.alibaba.com> wrote:
> 
>> Hi, Ingo
>> 
>> Another way to write SHT_PROGBITS is using elf_create_section to write orc_lookup table headers, when orc_unwind_ip table and orc_unwind table are written. Is this a better solution?
>> 
>> diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
>> index 3f98dcfbc177..860d4dcec8e6 100644
>> --- a/tools/objtool/orc_gen.c
>> +++ b/tools/objtool/orc_gen.c
>> @@ -183,6 +183,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) {
> 
> Looks much nicer IMO.
> 
> Mind turning this into a proper patch that does it plus reverts the 
> hack?
> 
A new patchset is sent.

Thanks,
huaixin

> Thanks,
> 
> 	Ingo
diff mbox series

Patch

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index db600ef218d7..49f4f5bc6165 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -826,6 +826,8 @@ 
 		. += (((SIZEOF(.text) + LOOKUP_BLOCK_SIZE - 1) /	\
 			LOOKUP_BLOCK_SIZE) + 1) * 4;			\
 		orc_lookup_end = .;					\
+		/* HACK: force SHT_PROGBITS so sorttable can edit: */	\
+		BYTE(1);						\
 	}
 #else
 #define ORC_UNWIND_TABLE