public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@uni-koblenz.de>
To: Mark Mitchell <mark@codesourcery.com>, binutils@sourceware.cygnus.com
Subject: R_MIPS_GOT16 bug
Date: Wed, 04 Aug 1999 19:14:00 -0000	[thread overview]
Message-ID: <19990805041216.C22390@uni-koblenz.de> (raw)

Hi Mark,

Here is a test case for R_MIPS_GOT16 problem.  Let's take a look at the
disassembler output:

nuke:     file format elf32-bigmips

Disassembly of section .text:

00000000004000b0 <_ftext>:
	...

00000000004000d0 <hurz>:
  4000d0:	3c1c0fc0 	lui	$gp,0xfc0
  4000d4:	279c7f20 	addiu	$gp,$gp,32544
  4000d8:	0399e021 	addu	$gp,$gp,$t9

 -> will point to 0x10007ff0 == gp

  4000dc:	8f998030 	lw	$t9,-32720($gp)

 -> load from 0x10000020
    (Wrong, this address isn't even mapped, see below!)

  4000e0:	00000000 	nop
  4000e4:	273900d0 	addiu	$t9,$t9,208
  4000e8:	0320f809 	jalr	$t9
  4000ec:	00000000 	nop
  4000f0:	03e00008 	jr	$ra
	...

nuke:     file format elf32-bigmips

Contents of section .got:
 10000000 00000000 80000000 004000d0 00000000  .........@......
 10000010 00000000 00000000 00000000 00000000  ................

This .got only contains one a pointer to the function hurz, but no the
expected pointer to 0x400000.

The pointer to hurz will never be referenced, btw, it's dead garbage in
the .got.  Making hurz a local function doesn't change that.

nuke:     file format elf32-bigmips

Program Header:
0x70000000 off    0x0000000000000094 vaddr 0x0000000000400094 paddr 0x0000000000400094 align 2**2
         filesz 0x0000000000000018 memsz 0x0000000000000018 flags r--
    LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**12
         filesz 0x0000000000000100 memsz 0x0000000000000100 flags r-x
    LOAD off    0x0000000000001000 vaddr 0x0000000010000000 paddr 0x0000000010000000 align 2**12
         filesz 0x0000000000000020 memsz 0x0000000000000020 flags rw-
private flags = 5: [no abi set] [mips1] [not 32bitmode]

Seems the .got is quite a bit too large in our little test case ...

  Ralf

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1999-08-05 04:08 MEST by <ralf@gnu.org>
# Source directory was `/home/ralf/src/binutils'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    236 -rw-rw-r-- nuke-ld-9/Makefile
#    129 -rw-rw-r-- nuke-ld-9/s2.s
#     18 -rw-rw-r-- nuke-ld-9/s1.s
#
echo=echo
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh23252; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= nuke-ld-9/Makefile ==============
if test ! -d 'nuke-ld-9'; then
  $echo 'x -' 'creating directory' 'nuke-ld-9'
  mkdir 'nuke-ld-9'
fi
if test -f 'nuke-ld-9/Makefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'nuke-ld-9/Makefile' '(file already exists)'
else
  $echo 'x -' extracting 'nuke-ld-9/Makefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'nuke-ld-9/Makefile' &&
AS = mips-linux-as
LD = mips-linux-ld
OBJDUMP = mips-linux-objdump
X
ASFLAGS = -KPIC
X
all: nuke
X
X.PHONY: nuke
X
nuke: s1.o s2.o
X	$(LD) -o $@ -e 0 $^
X	$(OBJDUMP) -d $@
X
X.PHONY: clean distclean
X
clean distclean:
X	-rm -f nuke s1.o s2.o core
SHAR_EOF
  $shar_touch -am 0805040699 'nuke-ld-9/Makefile' &&
  chmod 0664 'nuke-ld-9/Makefile' ||
  $echo 'restore of' 'nuke-ld-9/Makefile' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'nuke-ld-9/Makefile:' 'MD5 check failed'
9df8cafbb6403d86975f9ee4d6c6e81a  nuke-ld-9/Makefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'nuke-ld-9/Makefile'`"
    test 236 -eq "$shar_count" ||
    $echo 'nuke-ld-9/Makefile:' 'original size' '236,' 'current size' "$shar_count!"
  fi
fi
# ============= nuke-ld-9/s2.s ==============
if test -f 'nuke-ld-9/s2.s' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'nuke-ld-9/s2.s' '(file already exists)'
else
  $echo 'x -' extracting 'nuke-ld-9/s2.s' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'nuke-ld-9/s2.s' &&
X		nop;nop;nop;nop
X
X		.ent	hurz
X		#.globl	hurz
hurz:		.set	noreorder
X		.cpload	$25
X		.set	reorder
X		jal	hurz
X		jr	$31
X		.end	hurz
SHAR_EOF
  $shar_touch -am 0805040299 'nuke-ld-9/s2.s' &&
  chmod 0664 'nuke-ld-9/s2.s' ||
  $echo 'restore of' 'nuke-ld-9/s2.s' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'nuke-ld-9/s2.s:' 'MD5 check failed'
5ea0d57b5e76dc86afed35e8a4c4a9b4  nuke-ld-9/s2.s
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'nuke-ld-9/s2.s'`"
    test 129 -eq "$shar_count" ||
    $echo 'nuke-ld-9/s2.s:' 'original size' '129,' 'current size' "$shar_count!"
  fi
fi
# ============= nuke-ld-9/s1.s ==============
if test -f 'nuke-ld-9/s1.s' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'nuke-ld-9/s1.s' '(file already exists)'
else
  $echo 'x -' extracting 'nuke-ld-9/s1.s' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'nuke-ld-9/s1.s' &&
X		nop;nop;nop;nop
SHAR_EOF
  $shar_touch -am 0805031599 'nuke-ld-9/s1.s' &&
  chmod 0664 'nuke-ld-9/s1.s' ||
  $echo 'restore of' 'nuke-ld-9/s1.s' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'nuke-ld-9/s1.s:' 'MD5 check failed'
836a4f9e4106ebe8e16326239e8cdda1  nuke-ld-9/s1.s
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'nuke-ld-9/s1.s'`"
    test 18 -eq "$shar_count" ||
    $echo 'nuke-ld-9/s1.s:' 'original size' '18,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh23252
exit 0

             reply	other threads:[~1999-08-04 19:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-04 19:14 Ralf Baechle [this message]
     [not found] <19990806035519.B872@uni-koblenz.de>
     [not found] ` <19990805192859R.mitchell@codesourcery.com>
     [not found]   ` <19990806170650.A1366@uni-koblenz.de>
     [not found]     ` <19990806124535D.mitchell@codesourcery.com>
1999-08-15 15:31       ` Ralf Baechle
1999-08-15 15:46         ` Mark Mitchell
1999-08-15 15:52           ` Ralf Baechle
1999-08-15 15:59             ` Mark Mitchell

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=19990805041216.C22390@uni-koblenz.de \
    --to=ralf@uni-koblenz.de \
    --cc=binutils@sourceware.cygnus.com \
    --cc=mark@codesourcery.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).