* [PATCH v4] vmlinux.lds: account for destructor sections
@ 2016-07-01 15:19 Dmitry Vyukov
2016-07-01 15:19 ` Dmitry Vyukov
2016-07-01 15:20 ` Dmitry Vyukov
0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Vyukov @ 2016-07-01 15:19 UTC (permalink / raw)
To: akpm, linux-kernel, stable, tglx, mingo, hpa, x86, arnd,
linux-arch, ryabinin.a.a
Cc: kasan-dev, glider, Dmitry Vyukov
If CONFIG_KASAN is enabled and gcc is configured with
--disable-initfini-array and/or gold linker is used,
gcc emits .ctors/.dtors and .text.startup/.text.exit
sections instead of .init_array/.fini_array.
.dtors section is not explicitly accounted in the linker
script and messes vvar/percpu layout. Want:
ffffffff822bfd80 D _edata
ffffffff822c0000 D __vvar_beginning_hack
ffffffff822c0000 A __vvar_page
ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
ffffffff822c1000 A __init_begin
ffffffff822c1000 D init_per_cpu__irq_stack_union
ffffffff822c1000 A __per_cpu_load
ffffffff822d3000 D init_per_cpu__gdt_page
Got:
ffffffff8279a600 D _edata
ffffffff8279b000 A __vvar_page
ffffffff8279c000 A __init_begin
ffffffff8279c000 D init_per_cpu__irq_stack_union
ffffffff8279c000 A __per_cpu_load
ffffffff8279e000 D __vvar_beginning_hack
ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
ffffffff827ae000 D init_per_cpu__gdt_page
This happens because __vvar_page and .vvar get different
addresses in arch/x86/kernel/vmlinux.lds.S:
. = ALIGN(PAGE_SIZE);
__vvar_page = .;
.vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
/* work around gold bug 13023 */
__vvar_beginning_hack = .;
Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
Merge .text.startup into init text.
Cc: <stable@vger.kernel.org> # v4.0+
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
---
Changes since v1:
- discard .dtors
- don't define .mem sections
Changes since v2:
- use 'vmlinux.lds' subsystem prefix instead of 'kasan'
Changes since v3:
- add 'Cc: <stable@vger.kernel.org> # v4.0+' tag
- CC linux-kernel@vger.kernel.org,akpm@linux-foundation.org
---
include/asm-generic/vmlinux.lds.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6a67ab9..081d0f2 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -542,15 +542,19 @@
#define INIT_TEXT \
*(.init.text) \
+ *(.text.startup) \
MEM_DISCARD(init.text)
#define EXIT_DATA \
*(.exit.data) \
+ *(.fini_array) \
+ *(.dtors) \
MEM_DISCARD(exit.data) \
MEM_DISCARD(exit.rodata)
#define EXIT_TEXT \
*(.exit.text) \
+ *(.text.exit) \
MEM_DISCARD(exit.text)
#define EXIT_CALL \
--
2.8.0.rc3.226.g39d4020
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4] vmlinux.lds: account for destructor sections
2016-07-01 15:19 [PATCH v4] vmlinux.lds: account for destructor sections Dmitry Vyukov
@ 2016-07-01 15:19 ` Dmitry Vyukov
2016-07-01 15:20 ` Dmitry Vyukov
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Vyukov @ 2016-07-01 15:19 UTC (permalink / raw)
To: akpm, linux-kernel, stable, tglx, mingo, hpa, x86, arnd,
linux-arch, ryabinin.a.a
Cc: kasan-dev, glider, Dmitry Vyukov
If CONFIG_KASAN is enabled and gcc is configured with
--disable-initfini-array and/or gold linker is used,
gcc emits .ctors/.dtors and .text.startup/.text.exit
sections instead of .init_array/.fini_array.
.dtors section is not explicitly accounted in the linker
script and messes vvar/percpu layout. Want:
ffffffff822bfd80 D _edata
ffffffff822c0000 D __vvar_beginning_hack
ffffffff822c0000 A __vvar_page
ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
ffffffff822c1000 A __init_begin
ffffffff822c1000 D init_per_cpu__irq_stack_union
ffffffff822c1000 A __per_cpu_load
ffffffff822d3000 D init_per_cpu__gdt_page
Got:
ffffffff8279a600 D _edata
ffffffff8279b000 A __vvar_page
ffffffff8279c000 A __init_begin
ffffffff8279c000 D init_per_cpu__irq_stack_union
ffffffff8279c000 A __per_cpu_load
ffffffff8279e000 D __vvar_beginning_hack
ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
ffffffff827ae000 D init_per_cpu__gdt_page
This happens because __vvar_page and .vvar get different
addresses in arch/x86/kernel/vmlinux.lds.S:
. = ALIGN(PAGE_SIZE);
__vvar_page = .;
.vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
/* work around gold bug 13023 */
__vvar_beginning_hack = .;
Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
Merge .text.startup into init text.
Cc: <stable@vger.kernel.org> # v4.0+
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
---
Changes since v1:
- discard .dtors
- don't define .mem sections
Changes since v2:
- use 'vmlinux.lds' subsystem prefix instead of 'kasan'
Changes since v3:
- add 'Cc: <stable@vger.kernel.org> # v4.0+' tag
- CC linux-kernel@vger.kernel.org,akpm@linux-foundation.org
---
include/asm-generic/vmlinux.lds.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6a67ab9..081d0f2 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -542,15 +542,19 @@
#define INIT_TEXT \
*(.init.text) \
+ *(.text.startup) \
MEM_DISCARD(init.text)
#define EXIT_DATA \
*(.exit.data) \
+ *(.fini_array) \
+ *(.dtors) \
MEM_DISCARD(exit.data) \
MEM_DISCARD(exit.rodata)
#define EXIT_TEXT \
*(.exit.text) \
+ *(.text.exit) \
MEM_DISCARD(exit.text)
#define EXIT_CALL \
--
2.8.0.rc3.226.g39d4020
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] vmlinux.lds: account for destructor sections
2016-07-01 15:19 [PATCH v4] vmlinux.lds: account for destructor sections Dmitry Vyukov
2016-07-01 15:19 ` Dmitry Vyukov
@ 2016-07-01 15:20 ` Dmitry Vyukov
2016-07-01 15:20 ` Dmitry Vyukov
1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Vyukov @ 2016-07-01 15:20 UTC (permalink / raw)
To: Andrew Morton, LKML, stable, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, x86@kernel.org, Arnd Bergmann, linux-arch,
Andrey Ryabinin
Cc: kasan-dev, Alexander Potapenko, Dmitry Vyukov
On Fri, Jul 1, 2016 at 5:19 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> If CONFIG_KASAN is enabled and gcc is configured with
> --disable-initfini-array and/or gold linker is used,
> gcc emits .ctors/.dtors and .text.startup/.text.exit
> sections instead of .init_array/.fini_array.
> .dtors section is not explicitly accounted in the linker
> script and messes vvar/percpu layout. Want:
>
> ffffffff822bfd80 D _edata
> ffffffff822c0000 D __vvar_beginning_hack
> ffffffff822c0000 A __vvar_page
> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
> ffffffff822c1000 A __init_begin
> ffffffff822c1000 D init_per_cpu__irq_stack_union
> ffffffff822c1000 A __per_cpu_load
> ffffffff822d3000 D init_per_cpu__gdt_page
>
> Got:
>
> ffffffff8279a600 D _edata
> ffffffff8279b000 A __vvar_page
> ffffffff8279c000 A __init_begin
> ffffffff8279c000 D init_per_cpu__irq_stack_union
> ffffffff8279c000 A __per_cpu_load
> ffffffff8279e000 D __vvar_beginning_hack
> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
> ffffffff827ae000 D init_per_cpu__gdt_page
>
> This happens because __vvar_page and .vvar get different
> addresses in arch/x86/kernel/vmlinux.lds.S:
>
> . = ALIGN(PAGE_SIZE);
> __vvar_page = .;
>
> .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
> /* work around gold bug 13023 */
> __vvar_beginning_hack = .;
>
> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
> Merge .text.startup into init text.
>
> Cc: <stable@vger.kernel.org> # v4.0+
> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>
> ---
>
> Changes since v1:
> - discard .dtors
> - don't define .mem sections
>
> Changes since v2:
> - use 'vmlinux.lds' subsystem prefix instead of 'kasan'
>
> Changes since v3:
> - add 'Cc: <stable@vger.kernel.org> # v4.0+' tag
> - CC linux-kernel@vger.kernel.org,akpm@linux-foundation.org
Andrew, can you please take this to mm tree?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] vmlinux.lds: account for destructor sections
2016-07-01 15:20 ` Dmitry Vyukov
@ 2016-07-01 15:20 ` Dmitry Vyukov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Vyukov @ 2016-07-01 15:20 UTC (permalink / raw)
To: Andrew Morton, LKML, stable, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, x86@kernel.org, Arnd Bergmann, linux-arch,
Andrey Ryabinin
Cc: kasan-dev, Alexander Potapenko, Dmitry Vyukov
On Fri, Jul 1, 2016 at 5:19 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> If CONFIG_KASAN is enabled and gcc is configured with
> --disable-initfini-array and/or gold linker is used,
> gcc emits .ctors/.dtors and .text.startup/.text.exit
> sections instead of .init_array/.fini_array.
> .dtors section is not explicitly accounted in the linker
> script and messes vvar/percpu layout. Want:
>
> ffffffff822bfd80 D _edata
> ffffffff822c0000 D __vvar_beginning_hack
> ffffffff822c0000 A __vvar_page
> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
> ffffffff822c1000 A __init_begin
> ffffffff822c1000 D init_per_cpu__irq_stack_union
> ffffffff822c1000 A __per_cpu_load
> ffffffff822d3000 D init_per_cpu__gdt_page
>
> Got:
>
> ffffffff8279a600 D _edata
> ffffffff8279b000 A __vvar_page
> ffffffff8279c000 A __init_begin
> ffffffff8279c000 D init_per_cpu__irq_stack_union
> ffffffff8279c000 A __per_cpu_load
> ffffffff8279e000 D __vvar_beginning_hack
> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
> ffffffff827ae000 D init_per_cpu__gdt_page
>
> This happens because __vvar_page and .vvar get different
> addresses in arch/x86/kernel/vmlinux.lds.S:
>
> . = ALIGN(PAGE_SIZE);
> __vvar_page = .;
>
> .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
> /* work around gold bug 13023 */
> __vvar_beginning_hack = .;
>
> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
> Merge .text.startup into init text.
>
> Cc: <stable@vger.kernel.org> # v4.0+
> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>
> ---
>
> Changes since v1:
> - discard .dtors
> - don't define .mem sections
>
> Changes since v2:
> - use 'vmlinux.lds' subsystem prefix instead of 'kasan'
>
> Changes since v3:
> - add 'Cc: <stable@vger.kernel.org> # v4.0+' tag
> - CC linux-kernel@vger.kernel.org,akpm@linux-foundation.org
Andrew, can you please take this to mm tree?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-01 15:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-01 15:19 [PATCH v4] vmlinux.lds: account for destructor sections Dmitry Vyukov
2016-07-01 15:19 ` Dmitry Vyukov
2016-07-01 15:20 ` Dmitry Vyukov
2016-07-01 15:20 ` Dmitry Vyukov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox