* [PATCH 0/4] riscv: improve link and support ARCH_WANT_LD_ORPHAN_WARN
@ 2023-01-16 15:47 Jisheng Zhang
2023-01-16 15:47 ` [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT Jisheng Zhang
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Jisheng Zhang @ 2023-01-16 15:47 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor
Cc: linux-riscv
This series tries to improve link time handling of riscv:
patch1 adds the missing RUNTIME_DISCARD_EXIT as suggested by Masahiro.
Similar as other architectures such as x86, arm64 and so on, enable
ARCH_WANT_LD_ORPHAN_WARN to enable linker orphan warnings to prevent
from missing any new sections in future. So the following two patches
are preparation patches, and the last patch finally selects
ARCH_WANT_LD_ORPHAN_WARN
Jisheng Zhang (4):
riscv: lds: define RUNTIME_DISCARD_EXIT
riscv: vmlinux.lds.S: explicitly catch .rela.dyn symbols
riscv: vmlinux.lds.S: explicitly catch .riscv.attributes sections
riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL
arch/riscv/Kconfig | 1 +
arch/riscv/kernel/vmlinux.lds.S | 6 ++++++
2 files changed, 7 insertions(+)
--
2.38.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT
2023-01-16 15:47 [PATCH 0/4] riscv: improve link and support ARCH_WANT_LD_ORPHAN_WARN Jisheng Zhang
@ 2023-01-16 15:47 ` Jisheng Zhang
2023-01-16 16:43 ` Conor Dooley
2023-01-16 15:47 ` [PATCH 2/4] riscv: vmlinux.lds.S: explicitly catch .rela.dyn symbols Jisheng Zhang
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Jisheng Zhang @ 2023-01-16 15:47 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor
Cc: linux-riscv
riscv discards .exit.* sections at run-time but doesn't define
RUNTIME_DISCARD_EXIT. However, the .exit.* sections are still allocated
and kept even if the generic DISCARDS would discard the sections due
to missing RUNTIME_DISCARD_EXIT, because the DISCARD sits at the end of
the linker script. Add the missing RUNTIME_DISCARD_EXIT define so that
it still works if we move DISCARD up or even at the beginning of the
linker script.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
---
arch/riscv/kernel/vmlinux.lds.S | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 4e6c88aa4d87..07c19f2a288c 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -5,6 +5,7 @@
*/
#define RO_EXCEPTION_TABLE_ALIGN 4
+#define RUNTIME_DISCARD_EXIT
#ifdef CONFIG_XIP_KERNEL
#include "vmlinux-xip.lds.S"
--
2.38.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] riscv: vmlinux.lds.S: explicitly catch .rela.dyn symbols
2023-01-16 15:47 [PATCH 0/4] riscv: improve link and support ARCH_WANT_LD_ORPHAN_WARN Jisheng Zhang
2023-01-16 15:47 ` [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT Jisheng Zhang
@ 2023-01-16 15:47 ` Jisheng Zhang
2023-01-16 15:47 ` [PATCH 3/4] riscv: vmlinux.lds.S: explicitly catch .riscv.attributes sections Jisheng Zhang
2023-01-16 15:48 ` [PATCH 4/4] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL Jisheng Zhang
3 siblings, 0 replies; 9+ messages in thread
From: Jisheng Zhang @ 2023-01-16 15:47 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor
Cc: linux-riscv
When enabling linker orphan section warning, I got warnings similar as
below:
riscv64-linux-gnu-ld: warning: orphan section `.rela.text' from
`init/main.o' being placed in section `.rela.dyn'
Use the approach similar as ARM64 does and declare it in vmlinux.lds.S
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
arch/riscv/kernel/vmlinux.lds.S | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 07c19f2a288c..6a250313b752 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -97,6 +97,10 @@ SECTIONS
*(.rel.dyn*)
}
+ .rela.dyn : {
+ *(.rela*)
+ }
+
__init_data_end = .;
. = ALIGN(8);
--
2.38.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] riscv: vmlinux.lds.S: explicitly catch .riscv.attributes sections
2023-01-16 15:47 [PATCH 0/4] riscv: improve link and support ARCH_WANT_LD_ORPHAN_WARN Jisheng Zhang
2023-01-16 15:47 ` [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT Jisheng Zhang
2023-01-16 15:47 ` [PATCH 2/4] riscv: vmlinux.lds.S: explicitly catch .rela.dyn symbols Jisheng Zhang
@ 2023-01-16 15:47 ` Jisheng Zhang
2023-01-16 15:48 ` [PATCH 4/4] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL Jisheng Zhang
3 siblings, 0 replies; 9+ messages in thread
From: Jisheng Zhang @ 2023-01-16 15:47 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor
Cc: linux-riscv
When enabling linker orphan section warning, I got warnings similar as
below:
riscv64-linux-gnu-ld: warning: orphan section `.riscv.attributes' from
`init/main.o' being placed in section `.riscv.attributes'
While I don't see any usage of .riscv.attributes sections' usage in
kernel now, just catch the sections so that we can enable linker orphan
section warning.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
arch/riscv/kernel/vmlinux.lds.S | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 6a250313b752..7eb3d25d0dae 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -146,6 +146,7 @@ SECTIONS
STABS_DEBUG
DWARF_DEBUG
ELF_DETAILS
+ .riscv.attributes 0 : { *(.riscv.attributes) }
DISCARDS
}
--
2.38.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL
2023-01-16 15:47 [PATCH 0/4] riscv: improve link and support ARCH_WANT_LD_ORPHAN_WARN Jisheng Zhang
` (2 preceding siblings ...)
2023-01-16 15:47 ` [PATCH 3/4] riscv: vmlinux.lds.S: explicitly catch .riscv.attributes sections Jisheng Zhang
@ 2023-01-16 15:48 ` Jisheng Zhang
2023-01-17 10:21 ` Conor Dooley
3 siblings, 1 reply; 9+ messages in thread
From: Jisheng Zhang @ 2023-01-16 15:48 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor
Cc: linux-riscv
Now, after that all the sections are explicitly described and
declared in vmlinux.lds.S, we can enable ld orphan warnings for
!XIP_KERNEL to prevent from missing any new sections in future.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
arch/riscv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index e2b656043abf..335e0c45cced 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -46,6 +46,7 @@ config RISCV
select ARCH_WANT_FRAME_POINTERS
select ARCH_WANT_GENERAL_HUGETLB
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
+ select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
select BUILDTIME_TABLE_SORT if MMU
--
2.38.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT
2023-01-16 15:47 ` [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT Jisheng Zhang
@ 2023-01-16 16:43 ` Conor Dooley
2023-01-17 0:06 ` Jisheng Zhang
0 siblings, 1 reply; 9+ messages in thread
From: Conor Dooley @ 2023-01-16 16:43 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor, linux-riscv
[-- Attachment #1.1: Type: text/plain, Size: 1346 bytes --]
On Mon, Jan 16, 2023 at 11:47:57PM +0800, Jisheng Zhang wrote:
> riscv discards .exit.* sections at run-time but doesn't define
> RUNTIME_DISCARD_EXIT. However, the .exit.* sections are still allocated
> and kept even if the generic DISCARDS would discard the sections due
> to missing RUNTIME_DISCARD_EXIT, because the DISCARD sits at the end of
> the linker script. Add the missing RUNTIME_DISCARD_EXIT define so that
> it still works if we move DISCARD up or even at the beginning of the
> linker script.
>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> arch/riscv/kernel/vmlinux.lds.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
> index 4e6c88aa4d87..07c19f2a288c 100644
> --- a/arch/riscv/kernel/vmlinux.lds.S
> +++ b/arch/riscv/kernel/vmlinux.lds.S
> @@ -5,6 +5,7 @@
> */
>
> #define RO_EXCEPTION_TABLE_ALIGN 4
> +#define RUNTIME_DISCARD_EXIT
>
> #ifdef CONFIG_XIP_KERNEL
> #include "vmlinux-xip.lds.S"
Since the diff is identical to:
https://patchwork.kernel.org/project/linux-riscv/patch/20230102124936.1363533-1-conor@kernel.org/
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Your commit message is better anyways.
Thanks,
Conor.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT
2023-01-16 16:43 ` Conor Dooley
@ 2023-01-17 0:06 ` Jisheng Zhang
2023-01-17 6:27 ` Conor Dooley
0 siblings, 1 reply; 9+ messages in thread
From: Jisheng Zhang @ 2023-01-17 0:06 UTC (permalink / raw)
To: Conor Dooley
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor, linux-riscv
On Mon, Jan 16, 2023 at 04:43:05PM +0000, Conor Dooley wrote:
> On Mon, Jan 16, 2023 at 11:47:57PM +0800, Jisheng Zhang wrote:
> > riscv discards .exit.* sections at run-time but doesn't define
> > RUNTIME_DISCARD_EXIT. However, the .exit.* sections are still allocated
> > and kept even if the generic DISCARDS would discard the sections due
> > to missing RUNTIME_DISCARD_EXIT, because the DISCARD sits at the end of
> > the linker script. Add the missing RUNTIME_DISCARD_EXIT define so that
> > it still works if we move DISCARD up or even at the beginning of the
> > linker script.
> >
> > Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> > Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> > arch/riscv/kernel/vmlinux.lds.S | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
> > index 4e6c88aa4d87..07c19f2a288c 100644
> > --- a/arch/riscv/kernel/vmlinux.lds.S
> > +++ b/arch/riscv/kernel/vmlinux.lds.S
> > @@ -5,6 +5,7 @@
> > */
> >
> > #define RO_EXCEPTION_TABLE_ALIGN 4
> > +#define RUNTIME_DISCARD_EXIT
> >
> > #ifdef CONFIG_XIP_KERNEL
> > #include "vmlinux-xip.lds.S"
>
> Since the diff is identical to:
> https://patchwork.kernel.org/project/linux-riscv/patch/20230102124936.1363533-1-conor@kernel.org/
OOPS, I didn't notice you submitted the patch which did similar
about RUNTIME_DISCARD_EXIT, then I'd like to recall patch1. I
expected some review comments for remainning patch2\3\4, I will
send v2 which will both address possible review comments and
remove patch1
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> Your commit message is better anyways.
If you like it, you can take it into your v2 patch;)
Thanks
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT
2023-01-17 0:06 ` Jisheng Zhang
@ 2023-01-17 6:27 ` Conor Dooley
0 siblings, 0 replies; 9+ messages in thread
From: Conor Dooley @ 2023-01-17 6:27 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor, linux-riscv
On 17 January 2023 00:06:06 GMT, Jisheng Zhang <jszhang@kernel.org> wrote:
>On Mon, Jan 16, 2023 at 04:43:05PM +0000, Conor Dooley wrote:
>> On Mon, Jan 16, 2023 at 11:47:57PM +0800, Jisheng Zhang wrote:
>> > riscv discards .exit.* sections at run-time but doesn't define
>> > RUNTIME_DISCARD_EXIT. However, the .exit.* sections are still allocated
>> > and kept even if the generic DISCARDS would discard the sections due
>> > to missing RUNTIME_DISCARD_EXIT, because the DISCARD sits at the end of
>> > the linker script. Add the missing RUNTIME_DISCARD_EXIT define so that
>> > it still works if we move DISCARD up or even at the beginning of the
>> > linker script.
>> >
>> > Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
>> > Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
>> > ---
>> > arch/riscv/kernel/vmlinux.lds.S | 1 +
>> > 1 file changed, 1 insertion(+)
>> >
>> > diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
>> > index 4e6c88aa4d87..07c19f2a288c 100644
>> > --- a/arch/riscv/kernel/vmlinux.lds.S
>> > +++ b/arch/riscv/kernel/vmlinux.lds.S
>> > @@ -5,6 +5,7 @@
>> > */
>> >
>> > #define RO_EXCEPTION_TABLE_ALIGN 4
>> > +#define RUNTIME_DISCARD_EXIT
>> >
>> > #ifdef CONFIG_XIP_KERNEL
>> > #include "vmlinux-xip.lds.S"
>>
>> Since the diff is identical to:
>> https://patchwork.kernel.org/project/linux-riscv/patch/20230102124936.1363533-1-conor@kernel.org/
>
>OOPS, I didn't notice you submitted the patch which did similar
>about RUNTIME_DISCARD_EXIT, then I'd like to recall patch1. I
>expected some review comments for remainning patch2\3\4, I will
>send v2 which will both address possible review comments and
>remove patch1
Nah, keep your patch in the series.
I'll mark mine as superseded in patchwork.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL
2023-01-16 15:48 ` [PATCH 4/4] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL Jisheng Zhang
@ 2023-01-17 10:21 ` Conor Dooley
0 siblings, 0 replies; 9+ messages in thread
From: Conor Dooley @ 2023-01-17 10:21 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Masahiro Yamada,
Kees Cook, Nathan Chancellor, linux-riscv
[-- Attachment #1.1: Type: text/plain, Size: 994 bytes --]
Hey Jisheng,
On Mon, Jan 16, 2023 at 11:48:00PM +0800, Jisheng Zhang wrote:
> Now, after that all the sections are explicitly described and
> declared in vmlinux.lds.S, we can enable ld orphan warnings for
> !XIP_KERNEL to prevent from missing any new sections in future.
>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> ---
> arch/riscv/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index e2b656043abf..335e0c45cced 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -46,6 +46,7 @@ config RISCV
> select ARCH_WANT_FRAME_POINTERS
> select ARCH_WANT_GENERAL_HUGETLB
> select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
> + select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
Enabling this points out a bunch of warnings in the efi stub:
https://gist.github.com/conor-pwbot/145c5536268aec641671592a4cced32c
Would you mind sorting those out prior to enabling the warning?
Thanks,
Conor.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-01-17 10:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-16 15:47 [PATCH 0/4] riscv: improve link and support ARCH_WANT_LD_ORPHAN_WARN Jisheng Zhang
2023-01-16 15:47 ` [PATCH 1/4] riscv: lds: define RUNTIME_DISCARD_EXIT Jisheng Zhang
2023-01-16 16:43 ` Conor Dooley
2023-01-17 0:06 ` Jisheng Zhang
2023-01-17 6:27 ` Conor Dooley
2023-01-16 15:47 ` [PATCH 2/4] riscv: vmlinux.lds.S: explicitly catch .rela.dyn symbols Jisheng Zhang
2023-01-16 15:47 ` [PATCH 3/4] riscv: vmlinux.lds.S: explicitly catch .riscv.attributes sections Jisheng Zhang
2023-01-16 15:48 ` [PATCH 4/4] riscv: select ARCH_WANT_LD_ORPHAN_WARN for !XIP_KERNEL Jisheng Zhang
2023-01-17 10:21 ` Conor Dooley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox