From ffe54b3798db9112505e7f6b9d5e0d0b13823a29 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 4 Apr 2014 11:45:03 +1030 Subject: [PATCH] Pad sections according to current script FILL. When aligning input sections, we are supposed to take the fill pattern from a FILL statement, if there is one in the output section statement. ld/ * ldlang.c (lang_size_sections_1 ): Use current "fill", not "output_section_statement->fill". ld/testsuite/ * ld-scripts/fill.d, * ld-scripts/fill.t, * ld-scripts/fill_0.s, * ld-scripts/fill_1.s, * ld-scripts/fill_2.s: New test. * ld-scripts/data.exp: Run it. --- ld/ChangeLog | 5 +++++ ld/ldlang.c | 2 +- ld/testsuite/ChangeLog | 6 ++++++ ld/testsuite/ld-scripts/data.exp | 2 ++ ld/testsuite/ld-scripts/fill.d | 29 +++++++++++++++++++++++++++++ ld/testsuite/ld-scripts/fill.t | 20 ++++++++++++++++++++ ld/testsuite/ld-scripts/fill_0.s | 2 ++ ld/testsuite/ld-scripts/fill_1.s | 3 +++ ld/testsuite/ld-scripts/fill_2.s | 3 +++ 9 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-scripts/fill.d create mode 100644 ld/testsuite/ld-scripts/fill.t create mode 100644 ld/testsuite/ld-scripts/fill_0.s create mode 100644 ld/testsuite/ld-scripts/fill_1.s create mode 100644 ld/testsuite/ld-scripts/fill_2.s diff --git a/ld/ChangeLog b/ld/ChangeLog index d823aa4..5a3ddf2 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2014-04-04 Alan Modra + + * ldlang.c (lang_size_sections_1 ): Use + current "fill", not "output_section_statement->fill". + 2014-03-31 Nick Clifton PR ld/16744 diff --git a/ld/ldlang.c b/ld/ldlang.c index 37ef265..d147ee0 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -5213,7 +5213,7 @@ lang_size_sections_1 *relax = TRUE; } dot = size_input_section (prev, output_section_statement, - output_section_statement->fill, dot); + fill, dot); } break; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 0d36a4f..4d0fe20 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-04-04 Alan Modra + + * ld-scripts/fill.d, * ld-scripts/fill.t, * ld-scripts/fill_0.s, + * ld-scripts/fill_1.s, * ld-scripts/fill_2.s: New test. + * ld-scripts/data.exp: Run it. + 2014-03-31 Marcus Shawcroft * ld-aarch64/eh-frame.d: Adjust FDE pc address. diff --git a/ld/testsuite/ld-scripts/data.exp b/ld/testsuite/ld-scripts/data.exp index 052bec7..ad25e9b 100644 --- a/ld/testsuite/ld-scripts/data.exp +++ b/ld/testsuite/ld-scripts/data.exp @@ -23,7 +23,9 @@ # text segment, confusing run_dump_test. if {[is_aout_format]} { unsupported data + unsupported fill return } run_dump_test data +run_dump_test fill diff --git a/ld/testsuite/ld-scripts/fill.d b/ld/testsuite/ld-scripts/fill.d new file mode 100644 index 0000000..8dd789b --- /dev/null +++ b/ld/testsuite/ld-scripts/fill.d @@ -0,0 +1,29 @@ +#source: fill_0.s +#source: fill_1.s +#source: fill_2.s +#ld: -T fill.t +#objdump: -s -j .text +#xfail: ia64-*-* alpha-*-*ecoff m32c-*-* mips*-*-* sh-*-pe sparc*-*-coff +#xfail: tic30-*-coff tic4x-*-* tic54x-*-* +#xfail: x86_64-*-pe* x86_64-*-mingw* x86_64-*-cygwin z8k-*-* +# Breaks on ia64 due to minimum alignment of code. The section alignment +# could be increased to suit ia64 but then we'd break many coff targets +# that don't support alignment other than 4 bytes. +# alpha-linuxecoff always aligns code to 16 bytes. +# m32c pads out code sections to 8 bytes. +# mips aligns to 16 bytes +# sh-pe pads out code sections to 16 bytes +# sparc-coff aligns to 8 bytes +# tic30-coff aligns to 2 bytes +# tic4x has 4 octet bytes +# tic54x doesn't support .p2align +# x86_64-pe aligns to 16 bytes +# z8k-coff aligns to 2 bytes + +.*: file format .* + +Contents of section .text: + [0-9a-f]+ cafebabe 01010101 02020202 12232323 .* + [0-9a-f]+ 03030303 00345600 00004567 000089ab .* + [0-9a-f]+ (deadbeef|efbeadde) 00004567 000089ab 0000cdef .* + [0-9a-f]+ 00004567 000089ab 0000cdef 00000123 .* diff --git a/ld/testsuite/ld-scripts/fill.t b/ld/testsuite/ld-scripts/fill.t new file mode 100644 index 0000000..835e009 --- /dev/null +++ b/ld/testsuite/ld-scripts/fill.t @@ -0,0 +1,20 @@ +SECTIONS +{ + .text : + { + . += 4; + *0.o(.text) + FILL (0x12) + *1.o(.text) + . += 1; + FILL (0x23) + *2.o(.text) + FILL (0x003456) + . += 4; + FILL (0x00004567000089ab0000cdef00000123) + . += 8; + LONG (0xdeadbeef) + . += 12; + . += 16; + } =0xcafebabe +} diff --git a/ld/testsuite/ld-scripts/fill_0.s b/ld/testsuite/ld-scripts/fill_0.s new file mode 100644 index 0000000..2494a6e --- /dev/null +++ b/ld/testsuite/ld-scripts/fill_0.s @@ -0,0 +1,2 @@ + .text + .byte 1,1,1,1 diff --git a/ld/testsuite/ld-scripts/fill_1.s b/ld/testsuite/ld-scripts/fill_1.s new file mode 100644 index 0000000..2bbb28e --- /dev/null +++ b/ld/testsuite/ld-scripts/fill_1.s @@ -0,0 +1,3 @@ + .text + .p2align 2 + .byte 2,2,2,2 diff --git a/ld/testsuite/ld-scripts/fill_2.s b/ld/testsuite/ld-scripts/fill_2.s new file mode 100644 index 0000000..0b85fb5 --- /dev/null +++ b/ld/testsuite/ld-scripts/fill_2.s @@ -0,0 +1,3 @@ + .text + .p2align 2 + .byte 3,3,3,3 -- 2.7.4