From a0abb093ed595177a67a21f95c640dcfd7bc4e4c Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 16 Jan 2015 09:59:59 +0100 Subject: [PATCH] Remove output-section fill from linker scripts The linker scripts use to fill alignment gaps within the text section with the magic value 0x90909090, which correponds to the opcodes of four nop instructions on x86. This patch removes this value because it apparently solves no problem. If, for some reason (e.g., due to a dangling pointer) a thread executes instructions within alignment paddings, NOP instructions are not any better than any other instruction. The program will eventually execute the instructions after the padding, which is most likely fatal. It would be more reasonable to fill the padding with the opcode of an illegal instruction so that such an error can be immediately detected. That said, I cannot remember a single instance, where the fill value has helped us during debugging. Even if the mechanism served a purpose on x86, it is still better to remove it because it does not equally work on the other architectures where the linker scripts are used. I.e., on ARM, the opcode 0x90909090 is not a NOP instruction. --- repos/base-codezero/src/platform/genode.ld | 2 +- repos/base-nova/src/platform/roottask.ld | 2 +- repos/base-okl4/src/test/okl4_01_hello_raw/genode.ld | 2 +- repos/base/src/platform/genode.ld | 2 +- repos/base/src/platform/genode_dyn.ld | 6 +++--- repos/base/src/platform/genode_rel.ld | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/repos/base-codezero/src/platform/genode.ld b/repos/base-codezero/src/platform/genode.ld index 9a946a5b6..ac7a29f57 100644 --- a/repos/base-codezero/src/platform/genode.ld +++ b/repos/base-codezero/src/platform/genode.ld @@ -58,7 +58,7 @@ SECTIONS KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) _dtors_end = .; - } : ro = 0x90909090 + } : ro = 0x0 /* Linux: exception section for uaccess mechanism */ __ex_table : { *(__ex_table) } diff --git a/repos/base-nova/src/platform/roottask.ld b/repos/base-nova/src/platform/roottask.ld index 8b2894c62..d8e118543 100644 --- a/repos/base-nova/src/platform/roottask.ld +++ b/repos/base-nova/src/platform/roottask.ld @@ -49,7 +49,7 @@ SECTIONS KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) _dtors_end = .; - } : ro = 0x90909090 + } : ro = 0x0 /* Linux: exception section for uaccess mechanism */ __ex_table : { *(__ex_table) } diff --git a/repos/base-okl4/src/test/okl4_01_hello_raw/genode.ld b/repos/base-okl4/src/test/okl4_01_hello_raw/genode.ld index dc8593517..fbd6f1373 100644 --- a/repos/base-okl4/src/test/okl4_01_hello_raw/genode.ld +++ b/repos/base-okl4/src/test/okl4_01_hello_raw/genode.ld @@ -40,7 +40,7 @@ SECTIONS KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) _dtors_end = .; - } : ro = 0x90909090 + } : ro = 0x0 /* Linux: exception section for uaccess mechanism */ __ex_table : { *(__ex_table) } diff --git a/repos/base/src/platform/genode.ld b/repos/base/src/platform/genode.ld index b2a5289d1..d5cab593c 100644 --- a/repos/base/src/platform/genode.ld +++ b/repos/base/src/platform/genode.ld @@ -44,7 +44,7 @@ SECTIONS KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) _dtors_end = .; - } : ro = 0x90909090 + } : ro = 0x0 /* Linux: exception section for uaccess mechanism */ __ex_table : { *(__ex_table) } diff --git a/repos/base/src/platform/genode_dyn.ld b/repos/base/src/platform/genode_dyn.ld index 7402b301e..825412846 100644 --- a/repos/base/src/platform/genode_dyn.ld +++ b/repos/base/src/platform/genode_dyn.ld @@ -37,7 +37,7 @@ SECTIONS *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) - } : ro =0x90909090 + } : ro =0x0 .interp : { *(.interp) } : interp : ro .note.gnu.build-id : { *(.note.gnu.build-id) } @@ -77,13 +77,13 @@ SECTIONS .init : { KEEP (*(.init)) - } =0x90909090 + } = 0x0 .plt : { *(.plt) } .fini : { KEEP (*(.fini)) - } =0x90909090 + } = 0x0 PROVIDE (__etext = .); PROVIDE (_etext = .); PROVIDE (etext = .); diff --git a/repos/base/src/platform/genode_rel.ld b/repos/base/src/platform/genode_rel.ld index 7400a3776..d6891f760 100644 --- a/repos/base/src/platform/genode_rel.ld +++ b/repos/base/src/platform/genode_rel.ld @@ -66,18 +66,18 @@ SECTIONS .init : { KEEP (*(.init)) - } =0x90909090 + } = 0x0 .plt : { *(.plt) } .text : { *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) - } =0x90909090 + } = 0x0 .fini : { KEEP (*(.fini)) - } =0x90909090 + } =0x0 PROVIDE (__etext = .); PROVIDE (_etext = .); PROVIDE (etext = .);