Skip to content

Commit

Permalink
Added the testing directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Cupertino Miranda authored and Cupertino Miranda committed Oct 6, 2015
1 parent 201da15 commit 9a07ef9
Show file tree
Hide file tree
Showing 7 changed files with 864 additions and 0 deletions.
437 changes: 437 additions & 0 deletions testing/arclinux.sc

Large diffs are not rendered by default.

238 changes: 238 additions & 0 deletions testing/linker_script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc",
"elf32-littlearc")
OUTPUT_ARCH(arc)
ENTRY(__start)
SEARCH_DIR("/home/cmiranda/projects/arc-gcc_new/4.8.3-wk0/arc-elf32/lib");
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = 0x100); . = 0x100;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
.rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
.rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
.rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init :
{
KEEP (*(.init))
} =0
.plt : { *(.plt) }
.text :
{
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} =0
.text.init :
{
*(.text.init)
} =0
.fini :
{
KEEP (*(.fini))
} =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));
/* Exception handling */
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { *(.preinit_array) }
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { *(.init_array) }
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data.init :
{
*(.data.init)
}
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.dynamic : { *(.dynamic) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.got : { *(.got.plt) *(.got) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
__SDATA_BEGIN__ = .;
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
.sbss :
{
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
}
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
_end = .;
PROVIDE (end = .);
/* We want to be able to set a default stack / heap size in a dejagnu
board description file, but override it for selected test cases.
The options appear in the wrong order to do this with a single symbol -
ldflags comes after flags injected with per-file stanzas, and thus
the setting from ldflags prevails. */
.heap :
{
__start_heap = . ;
. = . + (DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : (DEFINED(__DEFAULT_HEAP_SIZE) ? __DEFAULT_HEAP_SIZE : 20k)) ;
__end_heap = . ;
}
. = ALIGN(0x8);
.stack :
{
__stack = . ;
. = . + (DEFINED(__STACK_SIZE) ? __STACK_SIZE : (DEFINED(__DEFAULT_STACK_SIZE) ? __DEFAULT_STACK_SIZE : 64k)) ;
__stack_top = . ;
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* ARC Extension Sections */
.arcextmap 0 : { *(.gnu.linkonce.arcextmap.*) }
/DISCARD/ : { *(.__arc_profile_*) }
/DISCARD/ : { *(.note.GNU-stack) }

. = 0x1a000000 ;

.data2 : {
*(.data2.*)
}
}
80 changes: 80 additions & 0 deletions testing/make_tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/ruby

require 'erb'
require_relative '../init.rb'

project_root = File.dirname(File.absolute_path(__FILE__))

output_path = ENV["BINUTILS_PATH"] || project_root + "/test_output/"
ld_output_path = "#{output_path}/ld/testsuite/ld-arc/relocs"
as_output_path = "#{output_path}/as/testsuite/as-arc/relocs"

`mkdir -p #{ld_output_path}`
`mkdir -p #{as_output_path}`

@tests = []

test_exp_renderer = ERB.new(File.open(project_root + "/templates/arc_reloc.exp.erb").read)
assembly_renderer = ERB.new(File.open(project_root + "/templates/reloc_test.s.erb").read)
validator_renderer = ERB.new(File.open(project_root + "/templates/reloc_test.d.erb").read)

def for_each_reloc_insn_tupple
Relocation.each do |reloc|
next if reloc.type =~ /none/
reloc.replacement_mask.instruction_operands.each do |io|
yield(reloc, io)
end
end
end

count = 0;
for_each_reloc_insn_tupple do
count += 1
end

progressbar = ProgressBar.create(
:format => '%a (%c/%C) %b|%i %p%% %t',
:starting_at => 0,
:total => count)

count = 0
for_each_reloc_insn_tupple do |reloc, io|
@reloc = reloc

@insn = io.instruction
@operand_reloc_number = io.number

# Linker test code
f = File.open(ld_output_path + "/#{@reloc.name}__#{@insn.mnemonic.downcase}__#{count}.s", "w")
f.write(assembly_renderer.result);
f.close
# Assembler test code
f = File.open(as_output_path + "/#{@reloc.name}__#{@insn.mnemonic.downcase}__#{count}.s", "w")
f.write(assembly_renderer.result);
f.close

# Linker validation files
f = File.open(ld_output_path + "/#{@reloc.name}__#{@insn.mnemonic.downcase}__#{count}.d", "w")
f.write(validator_renderer.result);
f.close
# Assembler validation files
f = File.open(as_output_path + "/#{@reloc.name}__#{@insn.mnemonic.downcase}__#{count}.d", "w")
f.write(validator_renderer.result);
f.close

@tests.push("#{@reloc.name}__#{@insn.mnemonic.downcase}__#{count}")
progressbar.increment
count += 1
end

f = File.open(ld_output_path + "/reloc.exp", "w")
f.write(test_exp_renderer.result);
f.close
f = File.open(as_output_path + "/reloc.exp", "w")
f.write(test_exp_renderer.result);
f.close

`cp relocs.ld #{ld_output_path}/`
`cp relocs.ld #{as_output_path}/`

exit 0
20 changes: 20 additions & 0 deletions testing/relocs.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc",
"elf32-littlearc")

OUTPUT_ARCH(arc)
ENTRY(__start)

SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__start = 0x10000);
. = 0x10000 + SIZEOF_HEADERS;

.text : {__SDATA_BEGIN__ = .; *(.text .stub .text.*)} =0
.sdata : {*(.sdata .sdata.*)}
.sbss : {*(.sbss .sbss.*)}

/DISCARD/ : { *(.__arc_profile_*) }
/DISCARD/ : { *(.note.GNU-stack) }
}
31 changes: 31 additions & 0 deletions testing/templates/arc_reloc.exp.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2015 Free Software Foundation
#
# This file is part of the GNU Binutils.
#
# This program 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
#

#
# ARC specific tests.
#

if {![istarget "arc*-*-*"]} {
return
}

<% @tests.each do |test| %>
run_dump_test "<%= test %>"
<% end %>
14 changes: 14 additions & 0 deletions testing/templates/reloc_test.d.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#source: start.s
#as:
#readelf: -S --wide
#ld:
#notarget: "ia64-*-*" "alpha*"

# Disabled on alpha because the entry point may be above 4GB but the stabs
# value on 32 bits.

#...
\[[0-9 ][0-9]\] \.stab +PROGBITS +0+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ +[1-9]+ +0.*
#...
\[[0-9 ][0-9]\] \.stabstr +STRTAB +0+ [0-9a-f]+ [0-9a-f]+ 00 +0 +0.*
#...
Loading

0 comments on commit 9a07ef9

Please sign in to comment.