This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bfd 2.10.90: Handle R_MIPS_REL32 relocations correctly


On Tue, 20 Jun 2000, Ulf Carlsson wrote:

> It still works fine.

 Weird.  I took today's binutils, reverted my fix and tried to link the
following program:

reloc.c:

#include <stdio.h>
#include <stdlib.h>

void (*myfree)(void *) = free;

int main(void)
{
	fprintf(stderr, "%p\n", myfree);
	fprintf(stderr, "%p\n", free);
	free(0);
	myfree(0);

	return 0;
}

 Then:

$ mipsel-linux-gcc -Bbinutils/usr/mipsel-linux/bin/ -v -pipe -c reloc.c
Reading specs from /usr/lib/gcc-lib/mipsel-linux/2.95.3/specs
gcc version 2.95.3 19991030 (prerelease)
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/cpp -lang-c -v -isystem binutils/usr/mipsel-linux/bin/include -D__GNUC__=2 -D__GNUC_MINOR__=95 -DMIPSEL -D_MIPSEL -Dunix -Dmips -D_mips -DR3000 -D_R3000 -Dlinux -D__ELF__ -D__PIC__ -D__pic__ -D__MIPSEL__ -D_MIPSEL -D__unix__ -D__mips__ -D___mips__ -D__R3000__ -D_R3000 -D__linux__ -D__ELF__ -D__PIC__ -D__pic__ -D__MIPSEL -D__unix -D__mips -D___mips -D__R3000 -D__linux -Asystem(posix) -Acpu(mips) -Amachine(mips) -D__LANGUAGE_C -D_LANGUAGE_C -DLANGUAGE_C -D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D_MIPS_FPSET=32 -D_MIPS_ISA=_MIPS_ISA_MIPS1 -D_ABIN32=2 -D_MIPS_SIM=_ABIN32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 -U__mips -D__mips -U__mips64 reloc.c |
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/cc1 -quiet -dumpbase reloc.c -version -o - |
 binutils/usr/mipsel-linux/bin/as -v -KPIC -o reloc.o
GNU CPP version 2.95.3 19991030 (prerelease) (MIPSel GNU/Linux with ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/include
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/../../../../mipsel-linux/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/../../../../mipsel-linux/include/g++-3
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/../../../../mipsel-linux/sys-include
End of omitted list.
GNU assembler version 2.10.90 (mipsel-linux) using BFD version 2.10.90
GNU C version 2.95.3 19991030 (prerelease) (mipsel-linux) compiled by GNU C version 2.95.3 19991030 (prerelease).
$ binutils/usr/bin/mipsel-linux-objdump -rt reloc.o

reloc.o:     file format elf32-littlemips

SYMBOL TABLE:
0000000000000000 l    d  .text	0000000000000000 
0000000000000000 l    d  .data	0000000000000000 
0000000000000000 l    d  .bss	0000000000000000 
0000000000000000 l    d  .rodata	0000000000000000 
0000000000000000 l    d  .reginfo	0000000000000000 
0000000000000000 l    d  .mdebug	0000000000000000 
0000000000000000 l    d  .note	0000000000000000 
0000000000000000 l       .text	0000000000000000 gcc2_compiled.
0000000000000000 l       .text	0000000000000000 __gnu_compiled_c
0000000000000000 g     O .data	0000000000000004 myfree
0000000000000000         *UND*	0000000000000000 free
0000000000000000 g     F .text	0000000000000108 main
0000000000000000       O *UND*	0000000000000000 _gp_disp
0000000000000000         *UND*	0000000000000000 __main
0000000000000000         *UND*	0000000000000000 stderr
0000000000000000         *UND*	0000000000000000 fprintf


RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE 
0000000000000000 R_MIPS_HI16       _gp_disp
0000000000000004 R_MIPS_LO16       _gp_disp
0000000000000024 R_MIPS_GOT16      __main
000000000000003c R_MIPS_GOT16      stderr
0000000000000048 R_MIPS_GOT16      .rodata
0000000000000050 R_MIPS_LO16       .rodata
0000000000000054 R_MIPS_GOT16      .data
000000000000005c R_MIPS_LO16       .data
0000000000000064 R_MIPS_GOT16      fprintf
000000000000007c R_MIPS_GOT16      stderr
0000000000000088 R_MIPS_GOT16      .rodata
0000000000000090 R_MIPS_LO16       .rodata
0000000000000094 R_MIPS_GOT16      free
0000000000000098 R_MIPS_GOT16      fprintf
00000000000000b0 R_MIPS_GOT16      free
00000000000000c8 R_MIPS_GOT16      .data
00000000000000d0 R_MIPS_LO16       .data


RELOCATION RECORDS FOR [.data]:
OFFSET           TYPE              VALUE 
0000000000000000 R_MIPS_32         free

$ mipsel-linux-gcc -Bbinutils/usr/mipsel-linux/bin/ -v -Wl,--verbose -o reloc reloc.o
Reading specs from /usr/lib/gcc-lib/mipsel-linux/2.95.3/specs
gcc version 2.95.3 19991030 (prerelease)
 /usr/lib/gcc-lib/mipsel-linux/2.95.3/collect2 -dynamic-linker /lib/ld.so.1 -o reloc /usr/mipsel-linux/lib/crt1.o /usr/mipsel-linux/lib/crti.o /usr/lib/gcc-lib/mipsel-linux/2.95.3/crtbegin.o -Lbinutils/usr/mipsel-linux/bin -L/usr/lib/gcc-lib/mipsel-linux/
2.95.3 -L/usr/mipsel-linux/lib --verbose reloc.o -lgcc -lc -lgcc /usr/lib/gcc-lib/mipsel-linux/2.95.3/crtend.o /usr/mipsel-linux/lib/crtn.o
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
GNU ld version 2.10.90 (with BFD 2.10.90)
  Supported emulations:
   elf32lsmip
   elf32bsmip
   mipslit
   mipsbig
using internal linker script:
==================================================
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
	      "elf32-littlemips")
OUTPUT_ARCH(mips)
ENTRY(__start)
 SEARCH_DIR(/usr/mipsel-linux/lib);
/* Do we need any of these for elf?
   __DYNAMIC = 0;    */
SECTIONS
{
  /* Read-only sections, merged into text segment: */
  . = 0x0400000 + SIZEOF_HEADERS;
  .interp     : { *(.interp) 	}
  .reginfo : { *(.reginfo) }
  .dynamic       : { *(.dynamic) }
  .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.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)		}
  .rela.sbss     : { *(.rela.sbss)	}
  .rel.sdata2    : { *(.rel.sdata2)	}
  .rela.sdata2   : { *(.rela.sdata2)	}
  .rel.sbss2     : { *(.rel.sbss2)	}
  .rela.sbss2    : { *(.rela.sbss2)	}
  .rel.bss       : { *(.rel.bss)		}
  .rela.bss      : { *(.rela.bss)		}
  .rel.plt       : { *(.rel.plt)		}
  .rela.plt      : { *(.rela.plt)		}
  .init          : 
  { 
    KEEP (*(.init))
  } =0
  .plt      : { *(.plt)	}
  .text      :
  {
    _ftext = . ;
    *(.text)
    *(.text.*)
    *(.stub)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.gnu.linkonce.t*)
    *(.mips16.fn.*) *(.mips16.call.*)
  } =0
  .fini      :
  {
    KEEP (*(.fini))
  } =0
  PROVIDE (__etext = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  .rodata   : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) }
  .rodata1   : { *(.rodata1) }
  .sdata2   : { *(.sdata2) }
  .sbss2   : { *(.sbss2) }
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  */
  . = 0x10000000;
  .data    :
  {
    _fdata = . ;
    *(.data)
    *(.data.*)
    *(.gnu.linkonce.d*)
    SORT(CONSTRUCTORS)
  }
  .data1   : { *(.data1) }
  .eh_frame : { KEEP (*(.eh_frame)) }
  .gcc_except_table : { *(.gcc_except_table) }
  .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))
  }
  _gp = ALIGN(16) + 0x7ff0;
  .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) 
    *(.sdata.*)
    *(.gnu.linkonce.s.*)
  }
  .lit8 : { *(.lit8) }
  .lit4 : { *(.lit4) }
  _edata = .;
  PROVIDE (edata = .);
  __bss_start = .;
  _fbss = .;
  .sbss      :
  {
    PROVIDE (__sbss_start = .);
    PROVIDE (___sbss_start = .);
    *(.dynsbss)
    *(.sbss)
    *(.sbss.*)
    *(.scommon)
    PROVIDE (__sbss_end = .);
    PROVIDE (___sbss_end = .);
  }
  .bss       :
  {
   *(.dynbss)
   *(.bss)
   *(.bss.*)
   *(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 = .);
  /* 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) }
  .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) }
  /* These must appear regardless of  .  */
  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
}


==================================================
attempt to open /usr/mipsel-linux/lib/crt1.o succeeded
/usr/mipsel-linux/lib/crt1.o
attempt to open /usr/mipsel-linux/lib/crti.o succeeded
/usr/mipsel-linux/lib/crti.o
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/crtbegin.o succeeded
/usr/lib/gcc-lib/mipsel-linux/2.95.3/crtbegin.o
attempt to open reloc.o succeeded
reloc.o
attempt to open binutils/usr/mipsel-linux/bin/libgcc.so failed
attempt to open binutils/usr/mipsel-linux/bin/libgcc.a failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.so failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a succeeded
(/usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a)__main.o
(/usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a)_ctors.o
(/usr/lib/gcc-lib/mipsel-linux/2.95.3/libgcc.a)_exit.o
attempt to open binutils/usr/mipsel-linux/bin/libc.so failed
attempt to open binutils/usr/mipsel-linux/bin/libc.a failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libc.so failed
attempt to open /usr/lib/gcc-lib/mipsel-linux/2.95.3/libc.a failed
attempt to open /usr/mipsel-linux/lib/libc.so succeeded
opened script file /usr/mipsel-linux/lib/libc.so
attempt to open /usr/mipsel-linux/lib/libc.so.6 succeeded
/usr/mipsel-linux/lib/libc.so.6
attempt to open /usr/mipsel-linux/lib/libc_nonshared.a succeeded
attempt to open binutils/usr/mipsel-linux/bin/libgcc.so failed
attempt to open binutils/usr/mipsel-linux/bin/libgcc.binutils/usr/mipsel-linux/bin/ld: bfd assertion fail elf32-mips.c:5660
mipsel-linux-gcc: file path prefix `binutils/usr/mipsel-linux/bin/' never used

 Perfectly repeateble.  After reapplying of the patch ld works again.

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]