pull from uClinux CVS
This commit is contained in:
parent
ee9c02846c
commit
e0b4700acf
@ -5,13 +5,13 @@
|
||||
/flat.h/1.6/Tue Jan 10 04:34:08 2006/-ko/
|
||||
/install-sh/1.1.1.1/Tue Jan 10 04:34:08 2006/-ko/
|
||||
/stubs.c/1.1/Tue Jan 10 04:34:08 2006//
|
||||
/flthdr.c/1.8/Tue Jan 10 05:11:20 2006/-ko/
|
||||
/elf2flt.ld/1.12/Tue Jan 10 05:12:32 2006/-ko/
|
||||
/config.sub/1.8/Wed Jan 11 13:36:39 2006/-ko/
|
||||
/cygwin-elf.h/1.4/Wed Jan 11 13:36:39 2006//
|
||||
/elf2flt.c/1.38/Fri Jan 13 08:02:22 2006/-ko/
|
||||
/Makefile.in/1.15/Result of merge/-ko/
|
||||
/configure.in/1.8/Mon Feb 6 05:04:36 2006/-ko/
|
||||
/ld-elf2flt.in/1.11/Mon Feb 6 05:04:36 2006//
|
||||
/configure/1.9/Mon Feb 6 05:05:05 2006/-ko/
|
||||
/Makefile.in/1.17/Result of merge/-ko/
|
||||
/configure/1.12/Sun Jan 28 05:27:28 2007/-ko/
|
||||
/configure.in/1.10/Sun Jan 28 05:27:28 2007/-ko/
|
||||
/elf2flt.c/1.46/Result of merge/-ko/
|
||||
/elf2flt.ld/1.15/Sun Jan 28 05:27:28 2007/-ko/
|
||||
/flthdr.c/1.10/Sun Jan 28 05:27:28 2007/-ko/
|
||||
/ld-elf2flt.in/1.15/Sun Jan 28 05:27:28 2007//
|
||||
D
|
||||
|
@ -66,10 +66,10 @@ install:
|
||||
$(INSTALL) -d $(bindir)
|
||||
$(INSTALL) -d $(target_bindir)
|
||||
$(INSTALL) -d $(target_libdir)
|
||||
$(INSTALL) -s -m 755 $(PROG_FLTHDR) $(bindir)/$(TARGET)-$(PROG_FLTHDR)
|
||||
$(INSTALL) -s -m 755 $(PROG_FLTHDR) $(target_bindir)/$(PROG_FLTHDR)
|
||||
$(INSTALL) -s -m 755 $(PROG_ELF2FLT) $(bindir)/$(TARGET)-$(PROG_ELF2FLT)
|
||||
$(INSTALL) -s -m 755 $(PROG_ELF2FLT) $(target_bindir)/$(PROG_ELF2FLT)
|
||||
$(INSTALL) -m 755 $(PROG_FLTHDR) $(bindir)/$(TARGET)-$(PROG_FLTHDR)
|
||||
$(INSTALL) -m 755 $(PROG_FLTHDR) $(target_bindir)/$(PROG_FLTHDR)
|
||||
$(INSTALL) -m 755 $(PROG_ELF2FLT) $(bindir)/$(TARGET)-$(PROG_ELF2FLT)
|
||||
$(INSTALL) -m 755 $(PROG_ELF2FLT) $(target_bindir)/$(PROG_ELF2FLT)
|
||||
[ -f $(bindir)/$(TARGET)-ld.real$(EXEEXT) ] || \
|
||||
mv $(bindir)/$(TARGET)-ld$(EXEEXT) $(bindir)/$(TARGET)-ld.real$(EXEEXT)
|
||||
[ -f $(target_bindir)/ld.real$(EXEEXT) ] || \
|
||||
|
792
toolchain/elf2flt/elf2flt/configure
vendored
792
toolchain/elf2flt/elf2flt/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,12 @@ AC_ARG_ENABLE(got-check,
|
||||
[ got_check=yes ]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE(emit_relocs,
|
||||
[ --disable-emit-relocs - don't use the --emit-relocs (-q) linker option ],
|
||||
[ emit_relocs=$enableval ],
|
||||
[ emit_relocs=yes ]
|
||||
)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
@ -75,29 +81,29 @@ fi
|
||||
binutils_ldscript_dir="$ac_binutils_ldscript_dir"
|
||||
|
||||
if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then
|
||||
echo
|
||||
echo "You need to specify the location of the libfd.a and libiberty.a"
|
||||
echo "host libraries from the binutils package."
|
||||
echo
|
||||
echo "Run configure again specifying these options:"
|
||||
echo
|
||||
echo " ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>"
|
||||
echo
|
||||
exit 1
|
||||
AC_MSG_ERROR([
|
||||
|
||||
You need to specify the location of the libfd.a and libiberty.a
|
||||
host libraries from the binutils package.
|
||||
|
||||
Run configure again specifying these options:
|
||||
|
||||
./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
|
||||
])
|
||||
fi
|
||||
|
||||
if test "$ac_bfd_include_dir" = "NONE" ; then
|
||||
echo
|
||||
echo "You need to specify the location of the bfd.h header from a"
|
||||
echo "configured/compiled version of the binutils package for your target."
|
||||
echo "Without this your elf2flt may crash as it will try to use the"
|
||||
echo "systems bfd.h which may be from a different binutils package."
|
||||
echo
|
||||
echo "Run configure again specifying these options:"
|
||||
echo
|
||||
echo " ./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>"
|
||||
echo
|
||||
exit 1
|
||||
AC_MSG_ERROR([
|
||||
|
||||
You need to specify the location of the bfd.h header from a
|
||||
configured/compiled version of the binutils package for your target.
|
||||
Without this your elf2flt may crash as it will try to use the
|
||||
systems bfd.h which may be from a different binutils package.
|
||||
|
||||
Run configure again specifying these options:
|
||||
|
||||
./configure --target=<ARCH> --with-bfd-include-dir=<dir> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
|
||||
])
|
||||
fi
|
||||
|
||||
dnl Checks for header files.
|
||||
@ -122,6 +128,7 @@ AC_SUBST(bfd_include_dir)
|
||||
AC_SUBST(binutils_include_dir)
|
||||
AC_SUBST(binutils_ldscript_dir)
|
||||
AC_SUBST(got_check)
|
||||
AC_SUBST(emit_relocs)
|
||||
|
||||
AC_OUTPUT(Makefile ld-elf2flt)
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
* ELF format file handling. Extended relocation support for all of
|
||||
* text and data.
|
||||
*
|
||||
* (c) 2006 Support the -a (use_resolved) option for TARGET_arm.
|
||||
* Shaun Jackman <sjackman@gmail.com>
|
||||
* (c) 2004, Nios II support, Wentao Xu <wentao@microtronix.com>
|
||||
* (c) 2003, H8 support, ktrace <davidm@snapgear.com>
|
||||
* (c) 2003-2004, MicroBlaze support, John Williams <jwilliams@itee.uq.edu.au>
|
||||
@ -44,8 +46,10 @@
|
||||
#include <time.h>
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h> /* Consts and structs defined by the internet system */
|
||||
#define BINARY_FILE_OPTS
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#define BINARY_FILE_OPTS "b"
|
||||
#endif
|
||||
|
||||
/* from $(INSTALLDIR)/include */
|
||||
@ -306,119 +310,6 @@ add_com_to_bss(asymbol **symbol_table, long number_of_symbols, long bss_len)
|
||||
}
|
||||
|
||||
#ifdef TARGET_bfin
|
||||
/* stack to handle "arithmetic" relocations */
|
||||
#define RELOC_STACK_SIZE 100
|
||||
static bfd_vma reloc_stack[RELOC_STACK_SIZE];
|
||||
static unsigned int reloc_stack_tos = 0;
|
||||
static char sym_section_name[80];
|
||||
static asection *stack_sym_section = 0;
|
||||
|
||||
static void
|
||||
reloc_stack_set_section(asection *section, const char *sym_section_name_in)
|
||||
{
|
||||
/* TODO : we can add checks to make sure we do not
|
||||
add different section names to the same arithmetic
|
||||
expression. */
|
||||
strcpy(sym_section_name, sym_section_name_in);
|
||||
stack_sym_section = section;
|
||||
}
|
||||
|
||||
static const char *
|
||||
reloc_stack_get_section_name()
|
||||
{
|
||||
return sym_section_name;
|
||||
}
|
||||
static asection *reloc_stack_get_section()
|
||||
{
|
||||
return stack_sym_section;
|
||||
}
|
||||
|
||||
#define is_reloc_stack_empty() ((reloc_stack_tos > 0)?0:1)
|
||||
|
||||
static void
|
||||
reloc_stack_push(bfd_vma value)
|
||||
{
|
||||
reloc_stack[reloc_stack_tos++] = value;
|
||||
}
|
||||
|
||||
static bfd_vma
|
||||
reloc_stack_pop()
|
||||
{
|
||||
return reloc_stack[--reloc_stack_tos];
|
||||
}
|
||||
|
||||
static bfd_vma
|
||||
reloc_stack_operate(unsigned int oper)
|
||||
{
|
||||
bfd_vma value;
|
||||
switch(oper){
|
||||
case 0xE2 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] + reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE3 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] - reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE4 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] * reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE5 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] / reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE6 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] % reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE7 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] << reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE8 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] >> reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xE9 :
|
||||
value = reloc_stack[reloc_stack_tos - 2] & reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xEA :
|
||||
value = reloc_stack[reloc_stack_tos - 2] | reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xEB :
|
||||
value = reloc_stack[reloc_stack_tos - 2] ^ reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xEC :
|
||||
value = reloc_stack[reloc_stack_tos - 2] && reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xED :
|
||||
value = reloc_stack[reloc_stack_tos - 2] || reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 2;
|
||||
break;
|
||||
case 0xEF :
|
||||
value = -reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos --;
|
||||
break;
|
||||
case 0xF0 :
|
||||
value = ~reloc_stack[reloc_stack_tos - 1];
|
||||
reloc_stack_tos -= 1;
|
||||
break;
|
||||
default :
|
||||
fprintf(stderr, "bfin relocation : Internal bug\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// now push the new value back on stack
|
||||
reloc_stack_push(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/* FUNCTION : weak_und_symbol
|
||||
ABSTRACT : return true if symbol is weak and undefined.
|
||||
*/
|
||||
@ -534,7 +425,7 @@ dump_symbols(symbols, number_of_symbols);
|
||||
* Also note that both the relocatable and absolute versions have this
|
||||
* terminator even though the relocatable one doesn't have the GOT!
|
||||
*/
|
||||
if (pic_with_got) {
|
||||
if (pic_with_got && !use_resolved) {
|
||||
unsigned long *lp = (unsigned long *)data;
|
||||
/* Should call ntohl(*lp) here but is isn't going to matter */
|
||||
while (*lp != 0xffffffff) lp++;
|
||||
@ -682,16 +573,6 @@ dump_symbols(symbols, number_of_symbols);
|
||||
#endif /* USE_V850_RELOCS */
|
||||
|
||||
q = *p;
|
||||
#ifdef TARGET_bfin
|
||||
if ((q->sym_ptr_ptr && *q->sym_ptr_ptr) &&
|
||||
(!is_reloc_stack_empty() && strstr((*(q->sym_ptr_ptr))->name, "operator"))){
|
||||
/* must be an arith reloc ... get the value from the stack */
|
||||
sym_name = (*(q->sym_ptr_ptr))->name;
|
||||
sym_section = reloc_stack_get_section();
|
||||
section_name = reloc_stack_get_section_name();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (q->sym_ptr_ptr && *q->sym_ptr_ptr) {
|
||||
sym_name = (*(q->sym_ptr_ptr))->name;
|
||||
sym_section = (*(q->sym_ptr_ptr))->section;
|
||||
@ -705,7 +586,7 @@ dump_symbols(symbols, number_of_symbols);
|
||||
/* Adjust the address to account for the GOT table which wasn't
|
||||
* present in the relative file link.
|
||||
*/
|
||||
if (pic_with_got)
|
||||
if (pic_with_got && !use_resolved)
|
||||
q->address += got_size;
|
||||
#endif
|
||||
|
||||
@ -793,7 +674,7 @@ dump_symbols(symbols, number_of_symbols);
|
||||
+ lo;
|
||||
}
|
||||
} else
|
||||
goto bad_v850_reloc_err;
|
||||
goto bad_resolved_reloc;
|
||||
break;
|
||||
|
||||
case R_V850_LO16:
|
||||
@ -807,16 +688,37 @@ dump_symbols(symbols, number_of_symbols);
|
||||
&& (p[-1]->addend == p[0]->addend))
|
||||
break; /* not an error */
|
||||
else
|
||||
goto bad_v850_reloc_err;
|
||||
goto bad_resolved_reloc;
|
||||
|
||||
case R_V850_HI16:
|
||||
bad_v850_reloc_err:
|
||||
printf("ERROR: reloc type %s unsupported in this context\n",
|
||||
q->howto->name);
|
||||
bad_relocs++;
|
||||
goto bad_resolved_reloc;
|
||||
default:
|
||||
goto good_32bit_resolved_reloc;
|
||||
#elif defined(TARGET_arm)
|
||||
case R_ARM_ABS32:
|
||||
relocation_needed = 1;
|
||||
break;
|
||||
#endif /* TARGET_V850 */
|
||||
|
||||
case R_ARM_REL32:
|
||||
case R_ARM_THM_PC11:
|
||||
case R_ARM_THM_PC22:
|
||||
relocation_needed = 0;
|
||||
break;
|
||||
default:
|
||||
goto bad_resolved_reloc;
|
||||
#elif defined(TARGET_m68k)
|
||||
case R_68K_32:
|
||||
goto good_32bit_resolved_reloc;
|
||||
case R_68K_PC32:
|
||||
case R_68K_PC16:
|
||||
/* The linker has already resolved
|
||||
PC relocs for us. In PIC links,
|
||||
the symbol must be in the data
|
||||
segment. */
|
||||
case R_68K_NONE:
|
||||
continue;
|
||||
default:
|
||||
goto bad_resolved_reloc;
|
||||
#else
|
||||
default:
|
||||
/* The default is to assume that the
|
||||
relocation is relative and has
|
||||
@ -825,6 +727,9 @@ dump_symbols(symbols, number_of_symbols);
|
||||
give an error by default, and
|
||||
require `safe' relocations to be
|
||||
enumberated explicitly?). */
|
||||
goto good_32bit_resolve_reloc;
|
||||
#endif
|
||||
good_32bit_resolved_reloc:
|
||||
if (bfd_big_endian (abs_bfd))
|
||||
sym_addr =
|
||||
(r_mem[0] << 24)
|
||||
@ -838,12 +743,19 @@ dump_symbols(symbols, number_of_symbols);
|
||||
+ (r_mem[2] << 16)
|
||||
+ (r_mem[3] << 24);
|
||||
relocation_needed = 1;
|
||||
break;
|
||||
|
||||
bad_resolved_reloc:
|
||||
printf("ERROR: reloc type %s unsupported in this context\n",
|
||||
q->howto->name);
|
||||
bad_relocs++;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Calculate the sym address ourselves. */
|
||||
sym_reloc_size = bfd_get_reloc_size(q->howto);
|
||||
|
||||
#if !defined(TARGET_h8300) && !defined(TARGET_e1) && !defined(TARGET_bfin)
|
||||
#if !defined(TARGET_h8300) && !defined(TARGET_e1) && !defined(TARGET_bfin) && !defined(TARGET_m68k)
|
||||
if (sym_reloc_size != 4) {
|
||||
printf("ERROR: bad reloc type %d size=%d for symbol=%s\n",
|
||||
(*p)->howto->type, sym_reloc_size, sym_name);
|
||||
@ -861,6 +773,7 @@ dump_symbols(symbols, number_of_symbols);
|
||||
sym_vma = bfd_section_vma(abs_bfd, sym_section);
|
||||
sym_addr += sym_vma + q->addend;
|
||||
break;
|
||||
case R_68K_PC16:
|
||||
case R_68K_PC32:
|
||||
sym_vma = 0;
|
||||
sym_addr += sym_vma + q->addend;
|
||||
@ -1278,14 +1191,12 @@ NIOS2_RELOC_ERR:
|
||||
sym_addr -= q->address; // make it PC relative
|
||||
// implicitly assumes code section and symbol section are same
|
||||
break;
|
||||
|
||||
case R_got:
|
||||
/* Ignore these. */
|
||||
break;
|
||||
|
||||
case R_rimm16:
|
||||
if (is_reloc_stack_empty ())
|
||||
{
|
||||
sym_addr += q->addend;
|
||||
} else {
|
||||
sym_addr = reloc_stack_pop ();
|
||||
}
|
||||
sym_addr += q->addend;
|
||||
if(weak_und_symbol(sym_section->name, (*(q->sym_ptr_ptr))))
|
||||
continue;
|
||||
if(0xFFFF0000 & sym_addr){
|
||||
@ -1315,11 +1226,8 @@ NIOS2_RELOC_ERR:
|
||||
else
|
||||
hi_lo = FLAT_RELOC_PART_HI;
|
||||
|
||||
if (is_reloc_stack_empty ())
|
||||
sym_addr += q->addend;
|
||||
else
|
||||
sym_addr = reloc_stack_pop ();
|
||||
|
||||
sym_addr += q->addend;
|
||||
|
||||
flat_relocs = (uint32_t *)
|
||||
(realloc (flat_relocs, (flat_reloc_count + 2) * sizeof (uint32_t)));
|
||||
reloc_count_incr = 1;
|
||||
@ -1356,10 +1264,8 @@ NIOS2_RELOC_ERR:
|
||||
break;
|
||||
}
|
||||
case R_byte4_data:
|
||||
if (is_reloc_stack_empty ())
|
||||
sym_addr += q->addend;
|
||||
else
|
||||
sym_addr = reloc_stack_pop ();
|
||||
sym_addr += q->addend;
|
||||
|
||||
if (weak_und_symbol (sym_section->name, *q->sym_ptr_ptr))
|
||||
continue;
|
||||
|
||||
@ -1375,22 +1281,6 @@ NIOS2_RELOC_ERR:
|
||||
flat_reloc_count++;
|
||||
break;
|
||||
|
||||
case 0xE0:
|
||||
/* push */
|
||||
sym_addr += q->addend;
|
||||
reloc_stack_push(sym_addr);
|
||||
reloc_stack_set_section(sym_section, section_name);
|
||||
break;
|
||||
|
||||
case 0xE1:
|
||||
/* const */
|
||||
reloc_stack_push(q->addend);
|
||||
break;
|
||||
|
||||
case 0xE2 ... 0xF2:
|
||||
reloc_stack_operate((*p)->howto->type);
|
||||
break;
|
||||
|
||||
#endif //TARGET_bfin
|
||||
|
||||
#ifdef TARGET_sh
|
||||
@ -1622,17 +1512,20 @@ DIS29_RELOCATION:
|
||||
|
||||
tmp.l = *(unsigned long *)r_mem;
|
||||
hl = tmp.c[i0] | (tmp.c[i1] << 8) | (tmp.c[i2] << 16);
|
||||
if (((*p)->howto->type != R_ARM_PC24) &&
|
||||
((*p)->howto->type != R_ARM_PLT32))
|
||||
if (use_resolved ||
|
||||
(((*p)->howto->type != R_ARM_PC24) &&
|
||||
((*p)->howto->type != R_ARM_PLT32)))
|
||||
hl |= (tmp.c[i3] << 24);
|
||||
else if (tmp.c[i2] & 0x80)
|
||||
hl |= 0xff000000; /* sign extend */
|
||||
hl += sym_addr;
|
||||
if (!use_resolved)
|
||||
hl += sym_addr;
|
||||
tmp.c[i0] = hl & 0xff;
|
||||
tmp.c[i1] = (hl >> 8) & 0xff;
|
||||
tmp.c[i2] = (hl >> 16) & 0xff;
|
||||
if (((*p)->howto->type != R_ARM_PC24) &&
|
||||
((*p)->howto->type != R_ARM_PLT32))
|
||||
if (use_resolved ||
|
||||
(((*p)->howto->type != R_ARM_PC24) &&
|
||||
((*p)->howto->type != R_ARM_PLT32)))
|
||||
tmp.c[i3] = (hl >> 24) & 0xff;
|
||||
if ((*p)->howto->type == R_ARM_ABS32)
|
||||
*(unsigned long *)r_mem = htonl(hl);
|
||||
@ -1734,6 +1627,18 @@ DIS29_RELOCATION:
|
||||
break;
|
||||
#endif /* TARGET_nios2 */
|
||||
|
||||
#if defined(TARGET_m68k)
|
||||
case R_68K_PC16:
|
||||
if (sym_addr < -0x8000 || sym_addr > 0x7fff) {
|
||||
fprintf (stderr, "Relocation overflow for R_68K_PC16 relocation against %s\n", sym_name);
|
||||
bad_relocs++;
|
||||
} else {
|
||||
r_mem[0] = (sym_addr >> 8) & 0xff;
|
||||
r_mem[1] = sym_addr & 0xff;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* The alignment of the build host
|
||||
might be stricter than that of the
|
||||
@ -1867,7 +1772,7 @@ static void write_zeroes (unsigned long num, FILE *stream)
|
||||
if (num > 0) {
|
||||
/* It'd be nice if we could just use fseek, but that doesn't seem to
|
||||
work for stdio output files. */
|
||||
bzero(zeroes, 1024);
|
||||
memset(zeroes, 0x00, 1024);
|
||||
while (num > sizeof(zeroes)) {
|
||||
fwrite(zeroes, sizeof(zeroes), 1, stream);
|
||||
num -= sizeof(zeroes);
|
||||
@ -2157,7 +2062,7 @@ int main(int argc, char *argv[])
|
||||
| (compress ? (compress == 2 ? FLAT_FLAG_GZDATA : FLAT_FLAG_GZIP) : 0)
|
||||
);
|
||||
hdr.build_date = htonl((unsigned long)time(NULL));
|
||||
bzero(hdr.filler, sizeof(hdr.filler));
|
||||
memset(hdr.filler, 0x00, sizeof(hdr.filler));
|
||||
|
||||
for (i=0; i<reloc_len; i++) reloc[i] = htonl(reloc[i]);
|
||||
|
||||
@ -2194,7 +2099,7 @@ int main(int argc, char *argv[])
|
||||
pclose(gf); \
|
||||
else \
|
||||
fclose(gf); \
|
||||
if (!(gf = popen(cmd, "wb"))) { \
|
||||
if (!(gf = popen(cmd, "w" BINARY_FILE_OPTS))) { \
|
||||
fprintf(stderr, "Can't run cmd %s\n", cmd); \
|
||||
exit(4); \
|
||||
} \
|
||||
|
@ -25,6 +25,7 @@ SECTIONS {
|
||||
W_RODAT *(.rodata)
|
||||
W_RODAT *(.rodata1)
|
||||
W_RODAT *(.rodata.*)
|
||||
W_RODAT *(.gnu.linkonce.r*)
|
||||
|
||||
/* This is special code area at the end of the normal
|
||||
text section. It contains a small lookup table at
|
||||
@ -53,7 +54,7 @@ W_RODAT *(.rodata.*)
|
||||
R_RODAT *(.rodata)
|
||||
R_RODAT *(.rodata1)
|
||||
R_RODAT *(.rodata.*)
|
||||
*(.gnu.linkonce.r*)
|
||||
R_RODAT *(.gnu.linkonce.r*)
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
@ -90,15 +91,48 @@ R_RODAT *(.rodata.*)
|
||||
. = ALIGN(4) ;
|
||||
__CTOR_LIST__ = .;
|
||||
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
|
||||
*(.ctors)
|
||||
SINGLE_LINK: /* gcc uses crtbegin.o to find the start of
|
||||
SINGLE_LINK: the constructors, so we make sure it is
|
||||
SINGLE_LINK: first. Because this is a wildcard, it
|
||||
SINGLE_LINK: doesn't matter if the user does not
|
||||
SINGLE_LINK: actually link against crtbegin.o; the
|
||||
SINGLE_LINK: linker won't look for a file to match a
|
||||
SINGLE_LINK: wildcard. The wildcard also means that it
|
||||
SINGLE_LINK: doesn't matter which directory crtbegin.o
|
||||
SINGLE_LINK: is in. */
|
||||
SINGLE_LINK: KEEP (*crtbegin*.o(.ctors))
|
||||
SINGLE_LINK: /* We don't want to include the .ctor section from
|
||||
SINGLE_LINK: from the crtend.o file until after the sorted ctors.
|
||||
SINGLE_LINK: The .ctor section from the crtend file contains the
|
||||
SINGLE_LINK: end of ctors marker and it must be last */
|
||||
SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
|
||||
SINGLE_LINK: KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
LONG(0)
|
||||
__CTOR_END__ = .;
|
||||
__DTOR_LIST__ = .;
|
||||
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
|
||||
*(.dtors)
|
||||
SINGLE_LINK: KEEP (*crtbegin*.o(.dtors))
|
||||
SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
SINGLE_LINK: KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
LONG(0)
|
||||
__DTOR_END__ = .;
|
||||
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
|
||||
. = ALIGN(0x10) ;
|
||||
_edata = . ;
|
||||
} > flatmem
|
||||
|
@ -19,8 +19,10 @@
|
||||
/* macros for conversion between host and (internet) network byte order */
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h> /* Consts and structs defined by the internet system */
|
||||
#define BINARY_FILE_OPTS
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#define BINARY_FILE_OPTS "b"
|
||||
#endif
|
||||
|
||||
/* from uClinux-x.x.x/include/linux */
|
||||
@ -83,7 +85,7 @@ process_file(char *ifile, char *ofile)
|
||||
|
||||
*tfile = *tfile2 = '\0';
|
||||
|
||||
if ((ifp = fopen(ifile, "rb")) == NULL) {
|
||||
if ((ifp = fopen(ifile, "r" BINARY_FILE_OPTS)) == NULL) {
|
||||
fprintf(stderr, "Cannot open %s\n", ifile);
|
||||
return;
|
||||
}
|
||||
@ -206,7 +208,7 @@ process_file(char *ifile, char *ofile)
|
||||
|
||||
strcpy(tfile, "/tmp/flatXXXXXX");
|
||||
mkstemp(tfile);
|
||||
if ((ofp = fopen(tfile, "wb")) == NULL) {
|
||||
if ((ofp = fopen(tfile, "w" BINARY_FILE_OPTS)) == NULL) {
|
||||
fprintf(stderr, "Failed to open %s for writing\n", tfile);
|
||||
unlink(tfile);
|
||||
unlink(tfile2);
|
||||
@ -231,7 +233,7 @@ process_file(char *ifile, char *ofile)
|
||||
mkstemp(tfile2);
|
||||
|
||||
if (old_flags & FLAT_FLAG_GZDATA) {
|
||||
tfp = fopen(tfile2, "wb");
|
||||
tfp = fopen(tfile2, "w" BINARY_FILE_OPTS);
|
||||
if (!tfp) {
|
||||
fprintf(stderr, "Failed to open %s for writing\n", tfile2);
|
||||
exit(1);
|
||||
@ -242,7 +244,7 @@ process_file(char *ifile, char *ofile)
|
||||
}
|
||||
|
||||
sprintf(cmd, "gunzip >> %s", tfile2);
|
||||
tfp = popen(cmd, "wb");
|
||||
tfp = popen(cmd, "w" BINARY_FILE_OPTS);
|
||||
if(!tfp) {
|
||||
perror("popen");
|
||||
exit(1);
|
||||
@ -251,7 +253,7 @@ process_file(char *ifile, char *ofile)
|
||||
pclose(tfp);
|
||||
|
||||
fclose(ifp);
|
||||
ifp = fopen(tfile2, "rb");
|
||||
ifp = fopen(tfile2, "r" BINARY_FILE_OPTS);
|
||||
if (!ifp) {
|
||||
fprintf(stderr, "Failed to open %s for reading\n", tfile2);
|
||||
unlink(tfile);
|
||||
@ -264,7 +266,7 @@ process_file(char *ifile, char *ofile)
|
||||
printf("zflat %s --> %s\n", ifile, ofile);
|
||||
fclose(ofp);
|
||||
sprintf(cmd, "gzip -9 -f >> %s", tfile);
|
||||
ofp = popen(cmd, "wb");
|
||||
ofp = popen(cmd, "w" BINARY_FILE_OPTS);
|
||||
ofp_is_pipe = 1;
|
||||
} else if (new_flags & FLAT_FLAG_GZDATA) {
|
||||
printf("zflat-data %s --> %s\n", ifile, ofile);
|
||||
@ -272,7 +274,7 @@ process_file(char *ifile, char *ofile)
|
||||
sizeof(struct flat_hdr));
|
||||
fclose(ofp);
|
||||
sprintf(cmd, "gzip -9 -f >> %s", tfile);
|
||||
ofp = popen(cmd, "wb");
|
||||
ofp = popen(cmd, "w" BINARY_FILE_OPTS);
|
||||
ofp_is_pipe = 1;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,11 @@
|
||||
|
||||
LINKER="$0.real" # the original renamed-linker
|
||||
ELF2FLT="`expr $0 : '\(.*\)ld'`elf2flt"
|
||||
NM="`expr $0 : '\(.*\)ld'`nm"
|
||||
TOOLDIR="`dirname $0`" # let gcc find the tools for us
|
||||
OBJCOPY="`expr $0 : '\(.*\)ld'`objcopy"
|
||||
[ -f "$OBJCOPY" ] || OBJCOPY="$TOOLDIR/../../bin/@target_alias@-objcopy"
|
||||
OBJDUMP="`expr $OBJCOPY : '\(.*\)objcopy'`objdump"
|
||||
LDSCRIPTPATH="@binutils_ldscript_dir@" # and the scripts
|
||||
SHARED_ID=""
|
||||
NEWLDSCRIPT=""
|
||||
@ -92,10 +96,11 @@ then
|
||||
ARG1="$ARG1 $FINAL_ONLY"
|
||||
NEWLDSCRIPT=`mktemp /tmp/flt-XXXXXX`
|
||||
SEDOP=" -e s/^R_RODAT// -e /^W_RODAT/d"
|
||||
OBJCOPYOP=""
|
||||
if [ "$MOVDAT" ]
|
||||
then
|
||||
$LINKER -r -d -o "$OFILE.elf2flt" $ARG1 || exit $?
|
||||
if [ "`@target_alias@-objdump -h "$OFILE.elf2flt" | \
|
||||
if [ "`$OBJDUMP -h "$OFILE.elf2flt" | \
|
||||
egrep -A1 '[.]rodata' | grep RELOC`" ]
|
||||
then
|
||||
echo "warning: .rodata section contains relocations"
|
||||
@ -117,6 +122,7 @@ then
|
||||
# Non application modules enter via main not _start
|
||||
# SEDOP="$SEDOP -e 's/ENTRY (_start)/ENTRY (main)/'"
|
||||
SEDOP="$SEDOP -e s/\\(ENTRY.\\)(_start)/\1(lib_main)/"
|
||||
OBJCOPYOP="--localize-hidden --weaken"
|
||||
fi
|
||||
|
||||
# Provide the magic parameter that defines the library data segment pointer offset
|
||||
@ -126,6 +132,12 @@ then
|
||||
esac
|
||||
ARG1="$ARG1 -defsym $GOT_OFFSET=`expr ${SHARED_ID} '*' -4 - 4`"
|
||||
fi
|
||||
if [ "@emit_relocs@" = "yes" ]
|
||||
then
|
||||
SEDOP="$SEDOP -e s/^SINGLE_LINK://"
|
||||
else
|
||||
SEDOP="$SEDOP -e /^SINGLE_LINK:/d"
|
||||
fi
|
||||
|
||||
# provide a default linker script, we usually need one
|
||||
[ -z "$LDSCRIPT" ] && LDSCRIPT="${LDSCRIPTPATH}/elf2flt.ld"
|
||||
@ -143,23 +155,56 @@ then
|
||||
LDSCRIPT="$NEWLDSCRIPT"
|
||||
fi
|
||||
|
||||
if [ "@got_check@" = "no" ]
|
||||
if [ "@emit_relocs@" = "yes" ]
|
||||
then
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -d -o "$OFILE.elf" $ARG1 ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" $ARG1 ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -q -o "$OFILE.gdb" $ARG1 ||exit $?
|
||||
RFILE="$OFILE.gdb"
|
||||
FLTFLAGS="$FLTFLAGS -a"
|
||||
else
|
||||
$LINKER $EMUL -r -d -o "$OFILE.elf2flt" $ARG1 ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -o "$OFILE.elf" "$OFILE.elf2flt" ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" "$OFILE.elf2flt" ||exit $?
|
||||
rm -f "$OFILE.elf2flt"
|
||||
if [ "@got_check@" = "no" ]
|
||||
then
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -d -o "$OFILE.elf" $ARG1 ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" $ARG1 ||exit $?
|
||||
else
|
||||
$LINKER $EMUL -r -d -o "$OFILE.elf2flt" $ARG1 ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -o "$OFILE.elf" "$OFILE.elf2flt" ||exit $?
|
||||
$LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" "$OFILE.elf2flt" ||exit $?
|
||||
rm -f "$OFILE.elf2flt"
|
||||
fi
|
||||
RFILE="$OFILE.elf"
|
||||
fi
|
||||
if grep _GLOBAL_OFFSET_TABLE_ "$OFILE.gdb" > /dev/null
|
||||
if $NM "$OFILE.gdb" | grep _GLOBAL_OFFSET_TABLE_ > /dev/null
|
||||
then
|
||||
$ELF2FLT $FLTFLAGS -o "$OFILE" -p "$OFILE.gdb" "$OFILE.elf" || exit $?
|
||||
$ELF2FLT $FLTFLAGS -o "$OFILE" -p "$OFILE.gdb" "$RFILE" || exit $?
|
||||
else
|
||||
$ELF2FLT $FLTFLAGS -o "$OFILE" -r "$OFILE.elf" || exit $?
|
||||
$ELF2FLT $FLTFLAGS -o "$OFILE" -r "$RFILE" || exit $?
|
||||
fi
|
||||
rm -f "$OFILE.elf" # not needed for any reason
|
||||
if [ "$OBJCOPYOP" ]
|
||||
then
|
||||
if $OBJCOPY $OBJCOPYOP --help > /dev/null 2>&1
|
||||
then
|
||||
$OBJCOPY $OBJCOPYOP "$OFILE.gdb" ||exit $?
|
||||
else
|
||||
case " $OBJCOPYOP " in
|
||||
*" --localize-hidden "*)
|
||||
SYMS=`mktemp /tmp/flt-XXXXXX`
|
||||
$OBJDUMP --syms "$OFILE.gdb" > "$SYMS" ||exit $?
|
||||
sed -n 's/.*\(\.hidden\|\.internal\) \(.*\)/-L \2/p' < "$SYMS" > "$SYMS.hidden" ||exit $?
|
||||
if [ -s "$SYMS.hidden" ]
|
||||
then
|
||||
xargs ${VERBOSE:+-t} $OBJCOPY "$OFILE.gdb" < "$SYMS.hidden" ||exit $?
|
||||
fi
|
||||
rm -f "$SYMS" "$SYMS.hidden"
|
||||
;;
|
||||
esac
|
||||
case " $OBJCOPYOP " in
|
||||
*" --weaken "*)
|
||||
$OBJCOPY --weaken "$OFILE.gdb" ||exit $?
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
[ "$RFILE" = "$OFILE.gdb" ] || rm -f "$RFILE" # not needed for any reason
|
||||
rm -f "$NEWLDSCRIPT"
|
||||
exit 0
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user