public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Viktor Kutuzov <vkutuzov@accesssoftek.com>
Cc: <binutils@sourceware.org>
Subject: Re: [PATCH, Take 2] Gold: Added R_ARM_ABS8 relocation unit test
Date: Sun, 27 Sep 2009 07:35:00 -0000	[thread overview]
Message-ID: <mcrab0gsuvx.fsf@dhcp-172-17-9-151.mtv.corp.google.com> (raw)
In-Reply-To: <6231D46FED13417D8B4AA371623A37C2@andreic6e7fe55> (Viktor Kutuzov's message of "Thu\, 3 Sep 2009 16\:26\:12 -0700")

[-- Attachment #1: Type: text/plain, Size: 804 bytes --]

Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:

> Please find attached the updated patch for the R_ARM_ABS8 relocation unit test.

I appreciate all the hard work you've done here, but this doesn't seem
like the right approach to me.

For standard relocations like 8-bit absolute we can write a reasonably
standard test.  We don't need to write a target dependent test.

I think we can make these tests more robust by using special section
names.

I don't understand your check_relocation_abs test.  As far as I can
tell, what it tests is that the final value of a symbol is the value
in the object file plus the offset of the section in the executable.
It doesn't seem to test the relocation value.

What I'm thinking is something along the lines of the appended,
although that is incomplete.

Ian



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: reloc test --]
[-- Type: text/x-diff, Size: 6055 bytes --]

Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gold/configure.ac,v
retrieving revision 1.46
diff -u -r1.46 configure.ac
--- configure.ac	23 Jun 2009 18:10:41 -0000	1.46
+++ configure.ac	27 Sep 2009 07:34:02 -0000
@@ -180,6 +180,11 @@
 fi
 AC_SUBST(TARGETOBJS)
 
+DEFAULT_ELF_MACHINE="$default_machine"
+AC_SUBST(DEFAULT_ELF_MACHINE)
+DEFAULT_ELF_SIZE="$default_size"
+AC_SUBST(DEFAULT_ELF_SIZE)
+
 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_MACHINE, $default_machine,
 		   [Default machine code])
 AC_DEFINE_UNQUOTED(GOLD_DEFAULT_SIZE, $default_size,
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.103
diff -u -r1.103 Makefile.am
--- testsuite/Makefile.am	18 Sep 2009 20:02:21 -0000	1.103
+++ testsuite/Makefile.am	27 Sep 2009 07:34:03 -0000
@@ -25,6 +25,7 @@
 TEST_STRIP = $(top_builddir)/../binutils/strip-new
 TEST_AR = $(top_builddir)/../binutils/ar
 TEST_NM = $(top_builddir)/../binutils/nm-new
+TEST_AS = $(top_builddir)/../gas/as-new
 
 if PLUGINS
 LIBDL = -ldl
@@ -76,6 +77,20 @@
 binary_unittest_SOURCES = binary_unittest.cc
 
 
+# Test simple relocations
+check_SCRIPTS += relocs_test.sh
+check_DATA += relocs-syms.stdout relocs-secs.stdout relocs-size.stdout
+relocs.o: relocs.s
+	$(TEST_AS) --defsym CPU=$(DEFAULT_ELF_MACHINE) --defsym SIZE=$(DEFAULT_ELF_SIZE) -o $@ $<
+relocs: relocs.o gcctestdir/ld
+	gcctestdir/ld -N -o $@ --defsym global_sym=0x10 -Ttext 0 -e entry relocs.o
+relocs-syms.stdout: relocs
+	$(TEST_NM) relocs > $@
+relocs-secs.stdout: relocs
+	$(TEST_OBJDUMP) -s relocs > $@
+relocs-size.stdout: Makefile
+	echo $(DEFAULT_ELF_SIZE) > $@
+
 # ---------------------------------------------------------------------
 # These tests test the output of gold (end-to-end tests).  In
 # particular, they make sure that gold can link "difficult" object
@@ -670,7 +685,6 @@
 
 endif
 
-
 # Test --detect-odr-violations
 check_SCRIPTS += debug_msg.sh
 
Index: testsuite/relocs.s
===================================================================
RCS file: testsuite/relocs.s
diff -N testsuite/relocs.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/relocs.s	27 Sep 2009 07:34:03 -0000
@@ -0,0 +1,69 @@
+	.text
+entry:
+	.globl	entry
+	.8byte	0
+
+	.data
+	.8byte	0
+local_sym:
+	.8byte	0
+
+.macro	section	name
+.ifeqs	"CPU", "EM_ARM"
+	.section	\name,"aw",%progbits
+.else
+	.section	\name,"aw",@progbits
+.endif
+.endm
+
+	section	test_1_l
+	.byte	local_sym
+
+	section	test_1_g
+	.byte	global_sym
+
+	section	test_1_lp
+	.byte	local_sym - .
+
+	section	test_1_gp
+	.byte	global_sym - .
+
+	section	test_2_l
+	.2byte	local_sym
+
+	section	test_2_g
+	.2byte	global_sym
+
+	section	test_2_lp
+	.2byte	local_sym - .
+
+	section	test_2_gp
+	.2byte	global_sym - .
+
+	section	test_4_l
+	.4byte	local_sym
+
+	section	test_4_g
+	.4byte	global_sym
+
+	section	test_4_lp
+	.4byte	local_sym - .
+
+	section	test_4_gp
+	.4byte	global_sym - .
+
+.if	SIZE != 32
+
+	section	test_8_l
+	.8byte	local_sym
+
+	section	test_8_g
+	.8byte	global_sym
+
+	section	test_8_lp
+	.8byte	local_sym - .
+
+	section	test_8_gp
+	.8byte	global_sym - .
+
+.endif
Index: testsuite/relocs_test.sh
===================================================================
RCS file: testsuite/relocs_test.sh
diff -N testsuite/relocs_test.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/relocs_test.sh	27 Sep 2009 07:34:03 -0000
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Ian Lance Taylor <iant@google.com>.
+
+# This file is part of gold.
+
+# 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.
+
+# Test that basic relocations produce the right value.
+
+# Get the value of the symbol "local_sym".
+locval=`grep local_sym relocs-syms.stdout | sed -e 's/ .*//' -e 's/^0*//'`
+if ! expr "$locval" : '[0-9a-f][0-9a-f]' >/dev/null 2>&1; then
+  echo 1>&2 "local_sym value is ${locval}; expected two hex digits"
+  exit 1
+fi
+
+# Get the value of the symbol "global_sym", which should be 0x10.
+globval=`grep global_sym relocs-syms.stdout | sed -e 's/ .*//' -e 's/^0*//'`
+if test "$globval" != "10"; then
+  echo 1>&2 "global_sym value is ${globval}; expected two hex digits"
+  exit 1
+fi
+
+# Set the variable contents to the contents of section $1.
+get_contents()
+{
+  contents=`sed -ne "
+    /section $1:/ {
+      n
+      s/^ *[0-9a-fA-F]* //
+      s/  .*$//
+      s/ //g
+      p
+    }
+  " < relocs-secs.stdout`
+}
+
+# Verify that the contents of section $1 is either $2 or $3.
+check_contents()
+{
+  get_contents $1
+  if test "$contents" != "$2" -a "$contents" != "$3"; then
+    echo 1>&2 "Section $1 is '$contents'; expected '$2' or '$3'"
+    exit 1
+  fi
+}
+
+check_contents "test_1_l" "${locval}" "${locval}"
+check_contents "test_1_g" "${globval}" "${globval}"
+check_contents "test_2_l" "00${locval}" "${locval}00"
+check_contents "test_2_g" "00${globval}" "${globval}00"
+check_contents "test_4_l" "000000${locval}" "${locval}000000"
+check_contents "test_4_g" "000000${globval}" "${globval}000000"
+
+size=`cat relocs-size.stdout`
+if test "$size" != "32"; then
+  check_contents "test_8_l" "00000000000000${locval}" "${locval}00000000000000"
+  check_contents "test_8_g" "00000000000000${globval}" "${globval}00000000000000"
+fi
+
+exit 0

  reply	other threads:[~2009-09-27  7:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-13 15:09 [PATCH] gold: add cast to gold_unreachable to workaround gcc giving invalid "no return statement" warnings Mikolaj Zalewski
2009-08-14  8:34 ` Ian Lance Taylor
2009-08-14  9:28   ` Mikolaj Zalewski
2009-08-14  9:36     ` Ian Lance Taylor
2009-08-31 21:49 ` [PATCH] Gold: Added R_ARM_ABS8 relocation Viktor Kutuzov
2009-08-31 23:52   ` Gold: Testsuite Viktor Kutuzov
2009-09-01  0:46     ` Ian Lance Taylor
2009-09-01  1:02       ` Viktor Kutuzov
2009-09-01  2:10         ` Ian Lance Taylor
     [not found]           ` <6AE1604EE3EC5F4296C096518C6B77EEE56FBF60@mail.accesssoftek.com>
2009-09-02  1:31             ` Viktor Kutuzov
2009-09-01  0:56   ` [PATCH] Gold: Added R_ARM_ABS8 relocation Ian Lance Taylor
2009-09-01 19:53     ` [PATCH Take 2] " Viktor Kutuzov
2009-09-01 21:24       ` Ian Lance Taylor
2009-09-02  1:30         ` [PATCH] Gold: Added R_ARM_ABS8 relocation unit test Viktor Kutuzov
2009-09-16  0:23           ` [PATCH] Gold: Added R_ARM_GOT_PREL relocation and unit tests Viktor Kutuzov
2009-09-16  1:00             ` [Gold] Heads up. Working on interworking Viktor Kutuzov
2009-10-06 21:46               ` [GOLD] Heads up. Gold for mingw Viktor Kutuzov
2009-10-06 22:02                 ` Vincent R.
2009-10-06 22:26                   ` Viktor Kutuzov
2009-10-06 22:06                 ` Matt Rice
2009-10-07 15:31             ` [PATCH] Gold: Added R_ARM_GOT_PREL relocation and unit tests Ian Lance Taylor
     [not found]         ` <6AE1604EE3EC5F4296C096518C6B77EEE56FBF62@mail.accesssoftek.com>
2009-09-03 23:26           ` [PATCH, Take 2] Gold: Added R_ARM_ABS8 relocation unit test Viktor Kutuzov
2009-09-27  7:35             ` Ian Lance Taylor [this message]
2009-09-29 23:30               ` Viktor Kutuzov
2009-09-29 23:40                 ` Ian Lance Taylor
2009-09-11 17:50 Viktor Kutuzov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mcrab0gsuvx.fsf@dhcp-172-17-9-151.mtv.corp.google.com \
    --to=iant@google.com \
    --cc=binutils@sourceware.org \
    --cc=vkutuzov@accesssoftek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).