[syslinux] [PATCH] com32: Include .init_array section in .ctors in linker script

Matt Fleming matt at console-pimps.org
Thu Nov 1 03:01:16 PDT 2012


From: Matt Fleming <matt.fleming at intel.com>

GCC 4.7 now places pointers to functions with the 'constructor' and
'destructor' function attributes in .init_array and .fini_array
sections, respectively, whereas previously they were in the .ctors and
.dtors sections. This change breaks the ctors/dtors code as it only
expects function to be in the .ctors and .dtors sections, meaning the
ctors and dtors functions are never executed.

While a COM32_INIT() macro exists that places functions in the
.init_array section, no function makes use of it, so there should be
no fallout from this change.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>
---
 com32/lib/elf32.ld | 15 ++++-----------
 com32/lib/init.h   | 15 ---------------
 com32/lib/malloc.c |  1 -
 3 files changed, 4 insertions(+), 27 deletions(-)
 delete mode 100644 com32/lib/init.h

diff --git a/com32/lib/elf32.ld b/com32/lib/elf32.ld
index ddf6e04..16d10a3 100644
--- a/com32/lib/elf32.ld
+++ b/com32/lib/elf32.ld
@@ -75,17 +75,6 @@ SECTIONS
   {
     KEEP (*(.preinit_array))
   }
-  .init_array     :
-  {
-     KEEP (*(SORT(.init_array.*)))
-     KEEP (*(.init_array))
-  }
-  .fini_array     :
-  {
-    KEEP (*(.fini_array))
-    KEEP (*(SORT(.fini_array.*)))
-  }
- 
   .ctors          :
   {
   	__ctors_start = .;
@@ -93,6 +82,8 @@ SECTIONS
     KEEP (*(.ctors))
     KEEP (*(.ctors_modinit))
     KEEP (*(.ctors_modmain))
+    KEEP (*(SORT(.init_array.*)))
+    KEEP (*(.init_array))
   	__ctors_end = .;
   }
   
@@ -102,6 +93,8 @@ SECTIONS
     KEEP (*(SORT(.dtors.*)))
     KEEP (*(.dtors))
     KEEP (*(.dtors_modexit))
+    KEEP (*(.fini_array))
+    KEEP (*(SORT(.fini_array.*)))
   	__dtors_end = .;
   }
   
diff --git a/com32/lib/init.h b/com32/lib/init.h
deleted file mode 100644
index 2d98342..0000000
--- a/com32/lib/init.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * init.h
- *
- * Magic to set up initializers
- */
-
-#ifndef _INIT_H
-#define _INIT_H 1
-
-#include <inttypes.h>
-
-#define COM32_INIT(x) static const void * const  __COM32_INIT \
-	__attribute__((section(".init_array"),unused)) = (const void * const)&x
-
-#endif /* _INIT_H */
diff --git a/com32/lib/malloc.c b/com32/lib/malloc.c
index ec103ab..ce35f3d 100644
--- a/com32/lib/malloc.c
+++ b/com32/lib/malloc.c
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <com32.h>
 #include <syslinux/memscan.h>
-#include "init.h"
 #include "malloc.h"
 
 struct free_arena_header __malloc_head = {
-- 
1.7.11.7




More information about the Syslinux mailing list