This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] avoid intermingling executable and nonexecutable sections in a segment


Any objection to putting this on the 2.23 branch too?

Thanks,
Roland

On Wed, Nov 21, 2012 at 11:56 AM, Roland McGrath <mcgrathr@google.com> wrote:
> Here's what I've committed to trunk.
> OK for 2.23 branch too?
>
>
> Thanks,
> Roland
>
>
> ld/
> 2012-11-21  Roland McGrath  <mcgrathr@google.com>
>
>         * ld.h (ld_config_type): New flag member separate_code.
>         * emultempl/elf32.em
>         (gld${EMULATION_NAME}_before_parse): Set it based on $SEPARATE_CODE.
>         * ldlang.c (ldlang_override_segment_assignment): If it's set, then
>         always return TRUE when SEC_CODE differs between the sections.
>
> --- a/ld/emultempl/elf32.em
> +++ b/ld/emultempl/elf32.em
> @@ -104,6 +104,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`;
>  }
>
>  EOF
> --- a/ld/ld.h
> +++ b/ld/ld.h
> @@ -274,6 +274,9 @@ 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;
>
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -5361,6 +5361,12 @@ ldlang_override_segment_assignment (struct
> bfd_link_info * info ATTRIBUTE_UNUSED
>    if (current_section == NULL || previous_section == NULL)
>      return new_segment;
>
> +  /* If this flag is set, the target never wants code and non-code
> +     sections comingled in the same segment.  */
> +  if (config.separate_code
> +      && ((current_section->flags ^ previous_section->flags) & SEC_CODE))
> +    return TRUE;
> +
>    /* Find the memory regions associated with the two sections.
>       We call lang_output_section_find() here rather than scanning the list
>       of output sections looking for a matching section pointer because if


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]