Skip to contentSkip to conversation

arm64: move elf notes into readonly segment

PATCH In review Mark Salter 2 participants 4 messages Aug 23, 2013 – Aug 27, 2013 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: move elf notes into readonly segment

The current vmlinux.lds.S places the notes sections between the end of rw data and start of bss. This means that _edata doesn't really point to the end of data. Since notes are read-only, this patch moves them to the read-only segment so that _edata does point to the end of initialized rw data.

---
 arch/arm64/kernel/vmlinux.lds.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/vmlinux.lds.S +1 -2
index f5e5574..f8ab9d8 100644
@@ -71,6 +71,7 @@ SECTIONS
 
 	RO_DATA(PAGE_SIZE)
 	EXCEPTION_TABLE(8)
+	NOTES
 	_etext = .;			/* End of text and rodata section */
 
 	. = ALIGN(PAGE_SIZE);
@@ -122,8 +123,6 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
-	NOTES
-
 	BSS_SECTION(0, 0, 0)
 	_end = .;
 
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 24 lines · Mark Salter

The current vmlinux.lds.S places the notes sections between the end of rw data and start of bss. This means that _edata doesn't really point to the end of data. Since notes are read-only, this patch moves them to the read-only segment so that _edata does point to the end of initialized rw data.

---
 arch/arm64/kernel/vmlinux.lds.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/vmlinux.lds.S +1 -0
index f5e5574..f8ab9d8 100644
@@ -71,6 +71,7 @@ SECTIONS
 
 	RO_DATA(PAGE_SIZE)
 	EXCEPTION_TABLE(8)
+	NOTES
 	_etext = .;			/* End of text and rodata section */
 
 	. = ALIGN(PAGE_SIZE);

arch/arm64/kernel/vmlinux.lds.S SECTIONS · line 127

Quoted 7 lines
arch/arm64/kernel/vmlinux.lds.S +0 -2
@@ -122,8 +123,6 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
-	NOTES
-
 	BSS_SECTION(0, 0, 0)
 	_end = .;

The _edata is set before NOTES, so I don't fully understand where the problem is.

Signature · 1 line
Catalin
#2 lore raw
Quoted 28 lines · Catalin Marinas
Quoted 27 lines · Mark Salter

The current vmlinux.lds.S places the notes sections between the end of rw data and start of bss. This means that _edata doesn't really point to the end of data. Since notes are read-only, this patch moves them to the read-only segment so that _edata does point to the end of initialized rw data.

---
 arch/arm64/kernel/vmlinux.lds.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/vmlinux.lds.S +1 -0
index f5e5574..f8ab9d8 100644
@@ -71,6 +71,7 @@ SECTIONS
 
 	RO_DATA(PAGE_SIZE)
 	EXCEPTION_TABLE(8)
+	NOTES
 	_etext = .;			/* End of text and rodata section */
 
 	. = ALIGN(PAGE_SIZE);
@@ -122,8 +123,6 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
Quoted 8 lines

arch/arm64/kernel/vmlinux.lds.S SECTIONS · line 127

Quoted 4 lines
arch/arm64/kernel/vmlinux.lds.S +0 -2
-	NOTES
-
 	BSS_SECTION(0, 0, 0)
 	_end = .;

The _edata is set before NOTES, so I don't fully understand where the problem is.

The problem *is* _edata before the NOTES. We need a symbol to mark the end of initialized data. This should be _edata but _edata doesn't currently account for NOTES. In the EFI stub I'm working on, the PE/COFF header needs to know the end of the image. If we use _edata, we wouldn't include NOTES, so we're left with __bss_start. But _bss_start may not be exactly right because of alignment rounding and it is ugly to use for that purpose. So we either need a new symbol following NOTES, or move _edata past NOTES, or move NOTES. I chose the latter because NOTES are readonly and don't really need to be part of the RW segment.

--Mark

maintainer
#3 lore raw
Quoted 37 lines · Mark Salter
Quoted 28 lines · Catalin Marinas
Quoted 27 lines · Mark Salter

The current vmlinux.lds.S places the notes sections between the end of rw data and start of bss. This means that _edata doesn't really point to the end of data. Since notes are read-only, this patch moves them to the read-only segment so that _edata does point to the end of initialized rw data.

---
 arch/arm64/kernel/vmlinux.lds.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/vmlinux.lds.S +1 -0
index f5e5574..f8ab9d8 100644
@@ -71,6 +71,7 @@ SECTIONS
 
 	RO_DATA(PAGE_SIZE)
 	EXCEPTION_TABLE(8)
+	NOTES
 	_etext = .;			/* End of text and rodata section */
 
 	. = ALIGN(PAGE_SIZE);
@@ -122,8 +123,6 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
Quoted 8 lines

arch/arm64/kernel/vmlinux.lds.S SECTIONS · line 127

Quoted 4 lines
arch/arm64/kernel/vmlinux.lds.S +0 -2
-	NOTES
-
 	BSS_SECTION(0, 0, 0)
 	_end = .;

The _edata is set before NOTES, so I don't fully understand where the problem is.

Quoted 9 lines

The problem *is* _edata before the NOTES. We need a symbol to mark the end of initialized data. This should be _edata but _edata doesn't currently account for NOTES. In the EFI stub I'm working on, the PE/COFF header needs to know the end of the image. If we use _edata, we wouldn't include NOTES, so we're left with __bss_start. But _bss_start may not be exactly right because of alignment rounding and it is ugly to use for that purpose. So we either need a new symbol following NOTES, or move _edata past NOTES, or move NOTES. I chose the latter because NOTES are readonly and don't really need to be part of the RW segment.

OK, I got it now. I'll queue the patch for 3.12.

Thanks.

Signature · 1 line
Catalin