On 24 June 2015 at 10:21, Gao, Liming <liming....@intel.com> wrote:
> Ard:
>   I am not sure who remember the detail history. If no one knows it, I 
> suggest to keep them as-is.
>

Well, with the new 2.5 feature that actually makes code RO and data
XP, I think it would be nice to make sure that rodata lives in the
former region. But I won't insist.

Another thing I should point out is that the =0x90909090 should
probably be removed as well: it basically puts a NOP slide into every
padded region, which only makes it easier for the hackers. If correct
operation of the firmware relies on these NOPs, it is broken anyway
and should be fixed.

>   On alignment, do you suggest use ".text 0x1000 : ALIGN(0x1000) {"?
>

Well, the former 0x1000 is implied by the alignment, since the header
consumes around 0x260 bytes at the beginning of the image. The
important part is that ALIGN() comes /after/ the colon, so it results
in the section being annotated with this alignment. Putting ALIGN()
before the colon just aligns the current placement of the section, but
the value is not recorded as the section alignment.

-- 
Ard.


> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Tuesday, June 23, 2015 5:17 PM
> To: edk2-devel@lists.sourceforge.net
> Subject: Re: [edk2] [Patch 3/3] BaseTools: Added GCC ld script to support 4K 
> alignment.
>
> On 23 June 2015 at 10:19, Yingke Liu <yingke.d....@intel.com> wrote:
>> This script can be used to generate 4K aligned ELF file.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Yingke Liu <yingke.d....@intel.com>
>> ---
>>  BaseTools/Scripts/gcc-4K-align-ld-script | 44
>> ++++++++++++++++++++++++++++++++
>>  1 file changed, 44 insertions(+)
>>  create mode 100644 BaseTools/Scripts/gcc-4K-align-ld-script
>>
>> diff --git a/BaseTools/Scripts/gcc-4K-align-ld-script
>> b/BaseTools/Scripts/gcc-4K-align-ld-script
>> new file mode 100644
>> index 0000000..1338433
>> --- /dev/null
>> +++ b/BaseTools/Scripts/gcc-4K-align-ld-script
>> @@ -0,0 +1,44 @@
>> +/* OUTPUT_FORMAT(efi-bsdrv-x86_64) */ SECTIONS {
>> +  /* . = 0 + SIZEOF_HEADERS; */
>> +  . = 0x280;
>> +  .text ALIGN(0x1000) :
>
> This puts the .text section at a fixed offset of 0x1000, but doesn't annotate 
> the .text section as being 4K aligned.
>
> You should probably use
>
> .text : ALIGN(0x1000)
>
> here instead. Same below.
>
> However, can you explain why the text section needs the hole here?
> Isn't it enough to simply align .data ?
>
>> +  {
>> +    *(.text .stub .text.* .gnu.linkonce.t.*)
>> +    . = ALIGN(0x20);
>> +  } =0x90909090
>> +  .data ALIGN(0x1000) :
>> +  {
>> +    *(
>> +      .rodata .rodata.* .gnu.linkonce.r.*
>
> I realize that this was in the original file that you copied, but could 
> anyone comment on the reason .rodata was put into the .data section?
>
>> +      .data .data.* .gnu.linkonce.d.*
>> +      .bss .bss.*
>> +      *COM*
>> +    )
>> +    . = ALIGN(0x20);
>> +  }
>> +  .eh_frame ALIGN(0x1000) :
>> +  {
>> +    KEEP (*(.eh_frame))
>> +  }
>> +  .got ALIGN(0x1000) :
>> +  {
>> +    *(.got .got.*)
>> +    . = ALIGN(0x20);
>> +  }
>> +  .rela ALIGN(0x1000) :
>> +  {
>> +    *(.rela .rela.*)
>> +  }
>> +  /DISCARD/ : {
>> +    *(.note.GNU-stack) *(.gnu_debuglink)
>> +    *(.interp)
>> +    *(.dynsym)
>> +    *(.dynstr)
>> +    *(.dynamic)
>> +    *(.hash)
>> +    *(.comment)
>> +  }
>> +}
>> +
>> --
>> 1.9.5.msysgit.0
>>
>>
>> ----------------------------------------------------------------------
>> -------- Monitor 25 network devices or servers for free with
>> OpManager!
>> OpManager is web-based network management software that monitors
>> network devices and physical & virtual servers, alerts via email & sms
>> for fault. Monitor 25 devices for free with no restriction. Download
>> now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> ------------------------------------------------------------------------------
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors network 
> devices and physical & virtual servers, alerts via email & sms for fault. 
> Monitor 25 devices for free with no restriction. Download now 
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> ------------------------------------------------------------------------------
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to