diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2004-10-04 16:45:51 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2004-10-04 16:45:51 +0000 |
commit | bcaa7b3eb9571ac0699402a62bf1bfae3a263413 (patch) | |
tree | a3101f1a003e9bb9ff9579fc1a0c3d016cc52821 /ld/testsuite/ld-scripts | |
parent | a4f5ad884ecd1b56c973e0d562d97720140d1ec8 (diff) | |
download | gdb-bcaa7b3eb9571ac0699402a62bf1bfae3a263413.zip gdb-bcaa7b3eb9571ac0699402a62bf1bfae3a263413.tar.gz gdb-bcaa7b3eb9571ac0699402a62bf1bfae3a263413.tar.bz2 |
ld/
2004-10-04 H.J. Lu <hongjiu.lu@intel.com>
* NEWS: Mention SORT_BY_NAME, SORT_BY_ALIGNMENT and
--sort-section name|alignment.
* ld.texinfo: Document SORT_BY_NAME, SORT_BY_ALIGNMENT and
--sort-section name|alignment.
* ld.h (sort_type): New enum.
(wildcard_spec): Change the type of `sorted' to sort_type.
* ldgram.y (SORT): Removed.
(SORT_BY_NAME): Added.
(SORT_BY_ALIGNMENT): Added.
(wildcard_spec): Updated `sorted'. Handle SORT_BY_NAME and
SORT_BY_ALIGNMENT.
(input_section_spec_no_keep): Updated `sorted'.
(statement): Replace SORT with SORT_BY_NAME.
* ldlang.c (compare_section): New function to compare 2
sections with different sorting schemes.
(wild_sort): Updated. Use compare_section.
(update_wild_statements): New function.
(lang_process): Call update_wild_statements before
map_input_to_output_sections.
* ldlex.l (SORT_BY_NAME): New.
(SORT_BY_ALIGNMENT): New.
(SORT): Return SORT_BY_NAME.
* ldmain.c (sort_section): New. Defined.
(main): Initialize it to none.
* lexsup.c (option_values): Add OPTION_SORT_SECTION.
(ld_options): Add an entry for OPTION_SORT_SECTION.
(parse_args): Handle OPTION_SORT_SECTION.
* mri.c (mri_draw_tree): Updated `sorted'.
ld/testsuite/
2004-10-04 H.J. Lu <hongjiu.lu@intel.com>
* ld-scripts/sort.exp: New file for section sorting tests.
* ld-scripts/sort_b_a.d: Likewise
* ld-scripts/sort_b_a.s: Likewise
* ld-scripts/sort_b_a.t: Likewise
* ld-scripts/sort_b_a_a-1.d: Likewise
* ld-scripts/sort_b_a_a-2.d: Likewise
* ld-scripts/sort_b_a_a-3.d: Likewise
* ld-scripts/sort_b_a_a.t: Likewise
* ld-scripts/sort_b_a_n-1.d: Likewise
* ld-scripts/sort_b_a_n-2.d: Likewise
* ld-scripts/sort_b_a_n-3.d: Likewise
* ld-scripts/sort_b_a_n.t: Likewise
* ld-scripts/sort_b_n.d: Likewise
* ld-scripts/sort_b_n.s: Likewise
* ld-scripts/sort_b_n.t: Likewise
* ld-scripts/sort_b_n_a-1.d: Likewise
* ld-scripts/sort_b_n_a-2.d: Likewise
* ld-scripts/sort_b_n_a-3.d: Likewise
* ld-scripts/sort_b_n_a.t: Likewise
* ld-scripts/sort_b_n_n-1.d: Likewise
* ld-scripts/sort_b_n_n-2.d: Likewise
* ld-scripts/sort_b_n_n-3.d: Likewise
* ld-scripts/sort_b_n_n.t: Likewise
* ld-scripts/sort_n_a-a.s: Likewise
* ld-scripts/sort_n_a-b.s: Likewise
* ld-scripts/sort_no-1.d: Likewise
* ld-scripts/sort_no-2.d: Likewise
* ld-scripts/sort_no.t: Likewise
Diffstat (limited to 'ld/testsuite/ld-scripts')
28 files changed, 325 insertions, 0 deletions
diff --git a/ld/testsuite/ld-scripts/sort.exp b/ld/testsuite/ld-scripts/sort.exp new file mode 100644 index 0000000..af88223 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort.exp @@ -0,0 +1,26 @@ +# Test SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT in a linker script. +# By H.J. Lu <hongjiu.lu@intel.com> +# Copyright 2004 +# Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +load_lib ld-lib.exp + +set sort_test_list [lsort [glob -nocomplain $srcdir/$subdir/sort*.d]] +for { set i 0 } { $i < [llength $sort_test_list] } { incr i } { + verbose [file rootname [lindex $sort_test_list $i]] + run_dump_test [file rootname [lindex $sort_test_list $i]] +} diff --git a/ld/testsuite/ld-scripts/sort_b_a.d b/ld/testsuite/ld-scripts/sort_b_a.d new file mode 100644 index 0000000..78fe1f1 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a.d @@ -0,0 +1,9 @@ +#source: sort_b_a.s +#ld: -T sort_b_a.t +#name: SORT_BY_ALIGNMENT +#nm: -n + +0[0-9a-f]* t text3 +0[0-9a-f]* t text1 +0[0-9a-f]* t text +0[0-9a-f]* t text2 diff --git a/ld/testsuite/ld-scripts/sort_b_a.s b/ld/testsuite/ld-scripts/sort_b_a.s new file mode 100644 index 0000000..7b3851f --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a.s @@ -0,0 +1,16 @@ + .section .text2 + .p2align 3 +text2: + .long 0 + .section .text3 + .p2align 6 +text3: + .long 0 + .section .text1 + .p2align 5 +text1: + .long 0 + .text +text: + .p2align 4 + .long 0 diff --git a/ld/testsuite/ld-scripts/sort_b_a.t b/ld/testsuite/ld-scripts/sort_b_a.t new file mode 100644 index 0000000..cbfd3c3 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_ALIGNMENT(.text*))} + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-scripts/sort_b_a_a-1.d b/ld/testsuite/ld-scripts/sort_b_a_a-1.d new file mode 100644 index 0000000..4f70646 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_a-1.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_a.t +#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) +#nm: -n + +0[0-9a-f]* t text3b +0[0-9a-f]* t text3a +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b diff --git a/ld/testsuite/ld-scripts/sort_b_a_a-2.d b/ld/testsuite/ld-scripts/sort_b_a_a-2.d new file mode 100644 index 0000000..65919a4 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_a-2.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_a.t --sort-section alignment +#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) --sort-section alignment +#nm: -n + +0[0-9a-f]* t text3b +0[0-9a-f]* t text3a +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b diff --git a/ld/testsuite/ld-scripts/sort_b_a_a-3.d b/ld/testsuite/ld-scripts/sort_b_a_a-3.d new file mode 100644 index 0000000..21b7732 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_a-3.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_a.t --sort-section name +#name: SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT()) --sort-section name +#nm: -n + +0[0-9a-f]* t text3b +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text3a +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b diff --git a/ld/testsuite/ld-scripts/sort_b_a_a.t b/ld/testsuite/ld-scripts/sort_b_a_a.t new file mode 100644 index 0000000..359cdff --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_a.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_ALIGNMENT(SORT_BY_ALIGNMENT(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-scripts/sort_b_a_n-1.d b/ld/testsuite/ld-scripts/sort_b_a_n-1.d new file mode 100644 index 0000000..62363bc --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_n-1.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_n.t +#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) +#nm: -n + +0[0-9a-f]* t text3b +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text3a +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b diff --git a/ld/testsuite/ld-scripts/sort_b_a_n-2.d b/ld/testsuite/ld-scripts/sort_b_a_n-2.d new file mode 100644 index 0000000..7402836 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_n-2.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_n.t --sort-section name +#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) --sort-section name +#nm: -n + +0[0-9a-f]* t text3b +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text3a +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b diff --git a/ld/testsuite/ld-scripts/sort_b_a_n-3.d b/ld/testsuite/ld-scripts/sort_b_a_n-3.d new file mode 100644 index 0000000..4421c77 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_n-3.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_a_n.t --sort-section alignment +#name: SORT_BY_ALIGNMENT(SORT_BY_NAME()) --sort-section alignment +#nm: -n + +0[0-9a-f]* t text3b +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text3a +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b diff --git a/ld/testsuite/ld-scripts/sort_b_a_n.t b/ld/testsuite/ld-scripts/sort_b_a_n.t new file mode 100644 index 0000000..04c3917 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_a_n.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-scripts/sort_b_n.d b/ld/testsuite/ld-scripts/sort_b_n.d new file mode 100644 index 0000000..531a756 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n.d @@ -0,0 +1,9 @@ +#source: sort_b_n.s +#ld: -T sort_b_n.t +#name: SORT_BY_NAME +#nm: -n + +0[0-9a-f]* t text +0[0-9a-f]* t text1 +0[0-9a-f]* t text2 +0[0-9a-f]* t text3 diff --git a/ld/testsuite/ld-scripts/sort_b_n.s b/ld/testsuite/ld-scripts/sort_b_n.s new file mode 100644 index 0000000..c99d75c --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n.s @@ -0,0 +1,12 @@ + .section .text2 +text2: + .long 0 + .section .text3 +text3: + .long 0 + .section .text1 +text1: + .long 0 + .text +text: + .long 0 diff --git a/ld/testsuite/ld-scripts/sort_b_n.t b/ld/testsuite/ld-scripts/sort_b_n.t new file mode 100644 index 0000000..26c2b6e --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_NAME(.text*))} + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-scripts/sort_b_n_a-1.d b/ld/testsuite/ld-scripts/sort_b_n_a-1.d new file mode 100644 index 0000000..ee123bf --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_a-1.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_a.t +#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) +#nm: -n + +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b +0[0-9a-f]* t text3b +0[0-9a-f]* t text3a diff --git a/ld/testsuite/ld-scripts/sort_b_n_a-2.d b/ld/testsuite/ld-scripts/sort_b_n_a-2.d new file mode 100644 index 0000000..82f1805 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_a-2.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_a.t --sort-section name +#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) --sort-section alignment +#nm: -n + +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b +0[0-9a-f]* t text3b +0[0-9a-f]* t text3a diff --git a/ld/testsuite/ld-scripts/sort_b_n_a-3.d b/ld/testsuite/ld-scripts/sort_b_n_a-3.d new file mode 100644 index 0000000..5f3c863 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_a-3.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_a.t --sort-section alignment +#name: SORT_BY_NAME(SORT_BY_ALIGNMENT()) --sort-section alignment +#nm: -n + +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b +0[0-9a-f]* t text3b +0[0-9a-f]* t text3a diff --git a/ld/testsuite/ld-scripts/sort_b_n_a.t b/ld/testsuite/ld-scripts/sort_b_n_a.t new file mode 100644 index 0000000..49cbdd3 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_a.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_NAME(SORT_BY_ALIGNMENT(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-scripts/sort_b_n_n-1.d b/ld/testsuite/ld-scripts/sort_b_n_n-1.d new file mode 100644 index 0000000..0bc18ae --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_n-1.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_n.t +#name: SORT_BY_NAME(SORT_BY_NAME()) +#nm: -n + +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b +0[0-9a-f]* t text3a +0[0-9a-f]* t text3b diff --git a/ld/testsuite/ld-scripts/sort_b_n_n-2.d b/ld/testsuite/ld-scripts/sort_b_n_n-2.d new file mode 100644 index 0000000..834bf90 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_n-2.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_n.t --sort-section name +#name: SORT_BY_NAME(SORT_BY_NAME()) --sort-section name +#nm: -n + +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b +0[0-9a-f]* t text3a +0[0-9a-f]* t text3b diff --git a/ld/testsuite/ld-scripts/sort_b_n_n-3.d b/ld/testsuite/ld-scripts/sort_b_n_n-3.d new file mode 100644 index 0000000..7ba8a8b --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_n-3.d @@ -0,0 +1,14 @@ +#source: sort_n_a-a.s +#source: sort_n_a-b.s +#ld: -T sort_b_n_n.t --sort-section alignment +#name: SORT_BY_NAME(SORT_BY_NAME()) --sort-section alignment +#nm: -n + +0[0-9a-f]* t texta +0[0-9a-f]* t textb +0[0-9a-f]* t text1a +0[0-9a-f]* t text1b +0[0-9a-f]* t text2a +0[0-9a-f]* t text2b +0[0-9a-f]* t text3b +0[0-9a-f]* t text3a diff --git a/ld/testsuite/ld-scripts/sort_b_n_n.t b/ld/testsuite/ld-scripts/sort_b_n_n.t new file mode 100644 index 0000000..b4eabfe --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_b_n_n.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(SORT_BY_NAME(SORT_BY_NAME(.text*)))} + /DISCARD/ : { *(.*) } +} diff --git a/ld/testsuite/ld-scripts/sort_n_a-a.s b/ld/testsuite/ld-scripts/sort_n_a-a.s new file mode 100644 index 0000000..77dfc35 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_n_a-a.s @@ -0,0 +1,16 @@ + .section .text2 + .p2align 3 +text2a: + .long 0 + .section .text3 + .p2align 5 +text3a: + .long 0 + .section .text1 + .p2align 5 +text1a: + .long 0 + .text +texta: + .p2align 4 + .long 0 diff --git a/ld/testsuite/ld-scripts/sort_n_a-b.s b/ld/testsuite/ld-scripts/sort_n_a-b.s new file mode 100644 index 0000000..781ba4e --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_n_a-b.s @@ -0,0 +1,16 @@ + .section .text2 + .p2align 3 +text2b: + .long 0 + .section .text3 + .p2align 6 +text3b: + .long 0 + .section .text1 + .p2align 5 +text1b: + .long 0 + .text +textb: + .p2align 4 + .long 0 diff --git a/ld/testsuite/ld-scripts/sort_no-1.d b/ld/testsuite/ld-scripts/sort_no-1.d new file mode 100644 index 0000000..aef7863 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_no-1.d @@ -0,0 +1,9 @@ +#source: sort_b_n.s +#ld: -T sort_no.t +#name: no SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT +#nm: -n + +0[0-9a-f]* t text +0[0-9a-f]* t text2 +0[0-9a-f]* t text3 +0[0-9a-f]* t text1 diff --git a/ld/testsuite/ld-scripts/sort_no-2.d b/ld/testsuite/ld-scripts/sort_no-2.d new file mode 100644 index 0000000..ddcd1c1 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_no-2.d @@ -0,0 +1,9 @@ +#source: sort_b_a.s +#ld: -T sort_no.t +#name: no SORT_BY_NAME/SORT_BY_ALIGNMENT/SORT +#nm: -n + +0[0-9a-f]* t text +0[0-9a-f]* t text2 +0[0-9a-f]* t text3 +0[0-9a-f]* t text1 diff --git a/ld/testsuite/ld-scripts/sort_no.t b/ld/testsuite/ld-scripts/sort_no.t new file mode 100644 index 0000000..d797c79 --- /dev/null +++ b/ld/testsuite/ld-scripts/sort_no.t @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : {*(.text*)} + /DISCARD/ : { *(.*) } +} |