ld: Remove separate_code from ld_config_type

Message ID 20180214131256.GA28641@gmail.com
State New
Headers show
Series
  • ld: Remove separate_code from ld_config_type
Related show

Commit Message

H.J. Lu Feb. 14, 2018, 1:12 p.m.
There are config.separate_code and link_info.separate_code. We should
always use link_info.separate_code.  This patch removes separate_code
from ld_config_type.

OK for master?

H.J.
---
	PR ld/22845
	* ld.h (ld_config_type): Remove separate_code.
	* ldlang.c (ldlang_override_segment_assignment): Check
	link_info.separate_code instead of config.separate_code.
	* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse):
	Set link_info.separate_code instead of config.separate_code.
	* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse):
	Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse):
	Likewise.
	* emultempl/mmixelf.em (gld${EMULATION_NAME}_before_parse):
	Likewise.
	* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse):
	Likewise.
---
 ld/emultempl/aarch64elf.em | 2 +-
 ld/emultempl/armelf.em     | 2 +-
 ld/emultempl/elf32.em      | 2 +-
 ld/emultempl/mmixelf.em    | 2 +-
 ld/emultempl/scoreelf.em   | 2 +-
 ld/ld.h                    | 3 ---
 ld/ldlang.c                | 2 +-
 7 files changed, 6 insertions(+), 9 deletions(-)

-- 
2.14.3

Comments

H.J. Lu Feb. 14, 2018, 8:23 p.m. | #1
On Wed, Feb 14, 2018 at 5:12 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> There are config.separate_code and link_info.separate_code. We should

> always use link_info.separate_code.  This patch removes separate_code

> from ld_config_type.

>

> OK for master?

>

> H.J.

> ---

>         PR ld/22845

>         * ld.h (ld_config_type): Remove separate_code.

>         * ldlang.c (ldlang_override_segment_assignment): Check

>         link_info.separate_code instead of config.separate_code.

>         * emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse):

>         Set link_info.separate_code instead of config.separate_code.

>         * emultempl/armelf.em (gld${EMULATION_NAME}_before_parse):

>         Likewise.

>         * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse):

>         Likewise.

>         * emultempl/mmixelf.em (gld${EMULATION_NAME}_before_parse):

>         Likewise.

>         * emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse):

>         Likewise.


Please ignore this.  They mean different things.

-- 
H.J.

Patch

diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index 629e1cc3ce..c2944462cb 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -42,7 +42,7 @@  gld${EMULATION_NAME}_before_parse (void)
 #endif /* not TARGET_ */
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
-  config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+  link_info.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   link_info.check_relocs_after_open_input = TRUE;
   link_info.relro = DEFAULT_LD_Z_RELRO;
 }
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 35908236ad..fe63bdbeca 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -57,7 +57,7 @@  gld${EMULATION_NAME}_before_parse (void)
 #endif /* not TARGET_ */
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
-  config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+  link_info.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   link_info.check_relocs_after_open_input = TRUE;
   link_info.relro = DEFAULT_LD_Z_RELRO;
 }
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index c0925fc9b9..4eb3b64761 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -102,7 +102,7 @@  gld${EMULATION_NAME}_before_parse (void)
   ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
-  config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+  link_info.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
   link_info.check_relocs_after_open_input = TRUE;
   link_info.relro = DEFAULT_LD_Z_RELRO;
diff --git a/ld/emultempl/mmixelf.em b/ld/emultempl/mmixelf.em
index 0fdbe51b4d..a7dcd628f2 100644
--- a/ld/emultempl/mmixelf.em
+++ b/ld/emultempl/mmixelf.em
@@ -39,7 +39,7 @@  elfmmix_before_parse (void)
      exclude this file.  */
   config.magic_demand_paged = FALSE;
 
-  config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+  link_info.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
 }
 EOF
 
diff --git a/ld/emultempl/scoreelf.em b/ld/emultempl/scoreelf.em
index 9774772686..823f468583 100644
--- a/ld/emultempl/scoreelf.em
+++ b/ld/emultempl/scoreelf.em
@@ -38,7 +38,7 @@  gld${EMULATION_NAME}_before_parse (void)
 #endif /* not TARGET_ */
   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
-  config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+  link_info.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   link_info.check_relocs_after_open_input = TRUE;
   link_info.relro = DEFAULT_LD_Z_RELRO;
 }
diff --git a/ld/ld.h b/ld/ld.h
index ba914b921e..7806a322bd 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -298,9 +298,6 @@  typedef struct
      numbers everywhere.  */
   bfd_boolean sane_expr;
 
-  /* If set, code and non-code sections should never be in one segment.  */
-  bfd_boolean separate_code;
-
   /* The rpath separation character.  Usually ':'.  */
   char rpath_separator;
 
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 001039d68b..a7ee3b68fb 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -5566,7 +5566,7 @@  ldlang_override_segment_assignment (struct bfd_link_info *info ATTRIBUTE_UNUSED,
 
   /* If this flag is set, the target never wants code and non-code
      sections comingled in the same segment.  */
-  if (config.separate_code
+  if (link_info.separate_code
       && ((current_section->flags ^ previous_section->flags) & SEC_CODE))
     return TRUE;