On 2015-07-28 12:37:31, Ard Biesheuvel wrote:
> On 28 July 2015 at 20:48, Jordan Justen <jordan.l.jus...@intel.com> wrote:
> > On 2015-07-24 05:08:34, Ard Biesheuvel wrote:
> >> This unifies all GCC linker scripts into a single parametrised GCC
> >> linker script that can be used for all GCC versions and architectures.
> >>
> >> The two parameters that can be set on the linker command line are:
> >> - PECOFF_HEADER_SIZE, this is a build time property of GenFw, but
> >>   its value is different between 32-bit and 64-bit;
> >> - common-page-size, this can be set using -z on the ld command line,
> >>   and controls the value of the COMMONPAGESIZE constant when used in
> >>   a linker script. This value is used for the minimum section alignment.
> >>
> >> Notable differences between the original versions:
> >> - .rodata has been moved into .text where it belongs;
> >> - the =90909090 NOP padding has been removed, since the only purpose it
> >>   serves is making it easier for hackers to launch exploits, whereas
> >>   correct code does not rely on these NOPs at all;
> >> - the .got contents have been moved into .text, but since we do not use
> >>   PIC code, this input section should always be empty anyway.
> >
> > These all sound reasonable, but wouldn't it be better to start with
> > the current script and make each of these changes one at a time?
> >
> 
> Perhaps, yes. But since this is a unification, some of these (the top
> two) are already present in gcc-aarch64-ld-script, on which this is
> mostly based.

Maybe first add each change to the linker scripts while they are
separate files, and in the end when they are all the same, you can
merge them into one script.

This might give us a chance to bisect, and it should help highlight
the various changes.

> >> Contributed-under: TianoCore Contribution Agreement 1.0
> >> Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
> >> ---
> >>  BaseTools/Scripts/GCC/gcc-base.lds | 62 ++++++++++++++++++++

I don't think we need the GCC directory. Ugh. Now I'm forced to
suggest that maybe it should be GccBase.lds, even though I didn't
follow the file naming convention with gcc4.4-ld-script. :)

> >>  1 file changed, 62 insertions(+)
> >>
> >> diff --git a/BaseTools/Scripts/GCC/gcc-base.lds 
> >> b/BaseTools/Scripts/GCC/gcc-base.lds
> >> new file mode 100644
> >> index 000000000000..e6109377ed38
> >> --- /dev/null
> >> +++ b/BaseTools/Scripts/GCC/gcc-base.lds
> >> @@ -0,0 +1,62 @@
> >> +/** @file
> >> +
> >> +  Unified linker script for GCC based builds
> >> +
> >> +  Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
> >
> > Is this file based on BaseTools/Scripts/gcc4.9-ld-script?
> >
> > If so, could you add this?
> >
> > Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
> >
> > Or, if it is based on BaseTools/Scripts/gcc-4K-align-ld-script:
> >
> > Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
> >
> 
> Since it is mostly a merge of all the different files, I will add the
> latter and retain the Linaro one, if that is ok with you.

Ok. Sounds good.

-Jordan

> >> +
> >> +  This program and the accompanying materials are licensed and made 
> >> available under
> >> +  the terms and conditions of the BSD License that accompanies this 
> >> distribution.
> >> +  The full text of the license may be found at
> >> +  http://opensource.org/licenses/bsd-license.php.
> >> +
> >> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> >> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> >> IMPLIED.
> >> +
> >> +**/
> >> +
> >> +SECTIONS {
> >> +
> >> +  /*
> >> +   * The PE/COFF binary consists of DOS and PE/COFF headers, and a 
> >> sequence of
> >> +   * section headers adding up to PECOFF_HEADER_SIZE bytes (which differs
> >> +   * between 32-bit and 64-bit builds). The actual start of the .text 
> >> section
> >> +   * will be rounded up based on its actual alignment.
> >> +   */
> >> +  . = PECOFF_HEADER_SIZE;
> >> +
> >> +  .text : ALIGN(CONSTANT(COMMONPAGESIZE)) {
> >> +    *(.text .text.* .stub .gnu.linkonce.t.*)
> >> +    *(.rodata .rodata.* .gnu.linkonce.r.*)
> >> +    *(.got .got.*)
> >> +  }
> >> +
> >> +  /*
> >> +   * The alignment of the .data section should be less than or equal to 
> >> the
> >> +   * alignment of the .text section. This ensures that the relative offset
> >> +   * between these sections is the same in the ELF and the PE/COFF 
> >> versions of
> >> +   * this binary.
> >> +   */
> >> +  .data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
> >> +    *(.data .data.* .gnu.linkonce.d.*)
> >> +    *(.bss .bss.* *COM*)
> >> +  }
> >> +
> >> +  .eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
> >> +    KEEP (*(.eh_frame))
> >> +  }
> >> +
> >> +  .rela ALIGN(CONSTANT(COMMONPAGESIZE)) : {
> >> +    *(.rela .rela.*)
> >> +  }
> >> +
> >> +  /DISCARD/ : {
> >> +    *(.note.GNU-stack)
> >> +    *(.gnu_debuglink)
> >> +    *(.interp)
> >> +    *(.dynsym)
> >> +    *(.dynstr)
> >> +    *(.dynamic)
> >> +    *(.hash)
> >> +    *(.comment)
> >> +  }
> >> +}
> >> --
> >> 1.9.1
> >>
> >> _______________________________________________
> >> edk2-devel mailing list
> >> edk2-devel@lists.01.org
> >> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to