]> git.wh0rd.org Git - elf2flt.git/log
elf2flt.git
8 years agoREADME.md: update email addresses
Greg Ungerer [Fri, 8 Jan 2016 01:36:17 +0000 (11:36 +1000)]
README.md: update email addresses

The @snapgear.com email addresses have not worked for years. Replace
them with up to data contact info.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agoR_H8_DIR24 fix
Yoshinori Sato [Wed, 30 Dec 2015 23:55:47 +0000 (00:55 +0100)]
R_H8_DIR24 fix

R_H8_DIR24A8 / R_H8_DIR24R8 keep all byte.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agoH8/300 relocation fix
Yoshinori Sato [Wed, 30 Dec 2015 23:55:46 +0000 (00:55 +0100)]
H8/300 relocation fix

Add new relocation R_H8_DISP32A16.
hi-byte clear on R_H8_DIR32 R_H8_DIR24A8 R_H8_DIR24R8 R_H8_DIR32A16 R_H8_DISP32A16

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agoconfigure: regenerate configure script
Greg Ungerer [Thu, 7 Jan 2016 11:48:16 +0000 (21:48 +1000)]
configure: regenerate configure script

Recent change to configure.ac to remove prefix symbol for h8300 requires
regeneration of the local configure script.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agorecent binutils for h8/300 no longer use prefix
Waldemar Brodkorb [Wed, 30 Dec 2015 23:55:44 +0000 (00:55 +0100)]
recent binutils for h8/300 no longer use prefix

Remove SYMBOL_PREFIX for h8/300.

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Signed-off-by: Yoshinori Sato <ysato@users.souceforge.jp>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agoconfigure: regenerate configure script
Greg Ungerer [Wed, 6 Jan 2016 01:20:10 +0000 (11:20 +1000)]
configure: regenerate configure script

Recent changes to configure.ac to add a dlopen check require a regeneration
of the local configure script.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agodlopen is used by newer binutils, so check for it
Waldemar Brodkorb [Tue, 5 Jan 2016 18:13:12 +0000 (19:13 +0100)]
dlopen is used by newer binutils, so check for it

Add a check for dlopen to configure.ac

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
8 years agoenable travis builds w/github
Mike Frysinger [Fri, 18 Dec 2015 02:55:28 +0000 (21:55 -0500)]
enable travis builds w/github

8 years agoREADME: use markdown
Mike Frysinger [Thu, 24 Dec 2015 06:25:31 +0000 (01:25 -0500)]
README: use markdown

This makes the file render nicely in github while still being readable.

8 years agostart a testsuite
Mike Frysinger [Thu, 24 Dec 2015 05:02:05 +0000 (00:02 -0500)]
start a testsuite

8 years agostandardize usage behavior
Mike Frysinger [Thu, 24 Dec 2015 04:38:24 +0000 (23:38 -0500)]
standardize usage behavior

Make sure the tools respect the -h (help) option, and exit 0 & use stdout
when called that way.  For all other cases, exit 1 & use stderr.

8 years agoflthdr: constify a few strings
Mike Frysinger [Thu, 24 Dec 2015 04:31:42 +0000 (23:31 -0500)]
flthdr: constify a few strings

8 years agoflthdr: fix print output w/no flags
Mike Frysinger [Thu, 24 Dec 2015 04:30:31 +0000 (23:30 -0500)]
flthdr: fix print output w/no flags

If the file has no flags, make sure we still include the closing paren
and newline in the output.

8 years agoconfigure: build with -Werror by default
Mike Frysinger [Fri, 18 Dec 2015 05:07:21 +0000 (00:07 -0500)]
configure: build with -Werror by default

People can pass --disable-werror to turn this off.  But this will help
keep the main development builds clean with new code coming in.

8 years agoelf2flt/ld-elf2flt: clean up build time warnings
Mike Frysinger [Fri, 18 Dec 2015 05:06:26 +0000 (00:06 -0500)]
elf2flt/ld-elf2flt: clean up build time warnings

8 years agoelf2flt: v850: fix build w/newer binutils
Mike Frysinger [Fri, 18 Dec 2015 04:59:29 +0000 (23:59 -0500)]
elf2flt: v850: fix build w/newer binutils

We need to include the v850 header directly for the right relocs,
and handle the renamed abs32 reloc.

8 years agoinstall: add DESTDIR support
Mike Frysinger [Fri, 18 Dec 2015 02:51:49 +0000 (21:51 -0500)]
install: add DESTDIR support

8 years agogitignore: update files
Mike Frysinger [Fri, 18 Dec 2015 02:43:45 +0000 (21:43 -0500)]
gitignore: update files

8 years agoautotools: regenerate
Mike Frysinger [Fri, 18 Dec 2015 02:40:41 +0000 (21:40 -0500)]
autotools: regenerate

8 years agoconfigure: rename input newer versions
Mike Frysinger [Fri, 18 Dec 2015 02:39:35 +0000 (21:39 -0500)]
configure: rename input newer versions

Newer autotools wants .ac suffix and warns/errors when using .in.

12 years agoFrom: Larry Baker <baker@usgs.gov>
Greg Ungerer [Thu, 4 Oct 2012 02:32:38 +0000 (02:32 +0000)]
From: Larry Baker <baker@usgs.gov>

The _stack_start symbol needs to be in the same flatmem memory region
as text/data/bss, otherwise it will not end up with the correct address.
Direct the section into the flatmem region.

Signed-of-by: Greg Ungerer <gerg@uclinux.org>
13 years agoThe GNU linker uses -v as a shortcut to --version, not --verbose. So atm,
David McCullough [Mon, 4 Apr 2011 01:17:17 +0000 (01:17 +0000)]
The GNU linker uses -v as a shortcut to --version, not --verbose.  So atm,
if you run `ld -v` to get the linker version, ld-elf2flt throws out a lot
of verbose debugging information.  So drop the -v checking in ld-elf2flt
to keep from breaking systems that parse the linker version.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
13 years agothe attached patch is needed for the recent elf2flt
David McCullough [Tue, 15 Feb 2011 23:22:26 +0000 (23:22 +0000)]
the attached patch is needed for the recent elf2flt
on MinGW builds. The stat() cannot cope with directories
ending with the directory separator.

Regards
Stanislav Meduna <stano@meduna.org>

13 years agoThe .note.ABI-tag section exists to indicate to other projects (like gdb
David McCullough [Thu, 16 Dec 2010 01:37:41 +0000 (01:37 +0000)]
The .note.ABI-tag section exists to indicate to other projects (like gdb
or library loaders) information about the target OS.  It doesn't actually
contain anything that is used at runtime.  So while the current linker
script gathers this into the .data section, the final FLAT doesn't include
anything from it.  But tools expect to find a dedicated section in ELFs
which the current section merge prevents.^M

So give .note.ABI-tag its own output section so gdb can locate and use it.
This shouldn't change the FLAT files produced in any way.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agoWhen we converted ld-elf2flt from the shell script to C, one small nuance
David McCullough [Tue, 17 Aug 2010 04:25:26 +0000 (04:25 +0000)]
When we converted ld-elf2flt from the shell script to C, one small nuance
was missed: argv[0] contains the full path only when invoked with the full
path.  This is not the same behavior for shell scripts as $0 is always the
full path to the script in question.  Most of the time this isn't an issue
as gcc will invoke all of its tools (like the linker) with a full relative
path to itself.  However, if we attempt to invoke the linker directly, we
can see misbehavior such as:
bfin-uclinux-ld.real: cannot open linker script file ./../lib/elf2flt.ld:
No such file or directory

So, to fix this, we lean on more libiberty functions.  Specifically, the
make_relative_prefix() function.  This function locates a full argv[0] by
scanning $PATH to see where it was invoked.  This might sound a little
dodgy, but this is fundamental to how gcc and binutils implement support
for their runtime relocation, so it can't break ld-elf2flt without first
breaking every one else ;).

In the fall out of this fix, we can cull a bunch of local code that does
custom path parsing.  So not only do we get to fix an annoying bug, we get
to shrink code in the process.

Signed-off-by: Steve Kilbane <steve@whitecrow.demon.co.uk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agoThe current code misses checking a few args in order to determine the
David McCullough [Tue, 22 Jun 2010 06:12:47 +0000 (06:12 +0000)]
The current code misses checking a few args in order to determine the
default "print" mode (ktrace/l1stack/...).  Rather than update a list
that people easily forget, rework the code to generically detect that
no arguments have been specified.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agoThe sed debug showed incorrect syntax for deletions, and the program exec
David McCullough [Tue, 11 May 2010 12:27:11 +0000 (12:27 +0000)]
The sed debug showed incorrect syntax for deletions, and the program exec
debug missed output redirection.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agoHere is a patch to fix a ``misunderstanding'' between the kernel (bflt
Greg Ungerer [Tue, 9 Mar 2010 06:19:11 +0000 (06:19 +0000)]
Here is a patch to fix a ``misunderstanding'' between the kernel (bflt
loader) and GDB; noticed on m68k / coldfire uClinux.

Lacking specific directives in the linker script, the linker *may* decide
to put .text and .data into the same segment:

     Section to Segment mapping:
      Segment Sections...
       00     .text .data .eh_frame_hdr .eh_frame .bss
       01     .eh_frame_hdr

The bflt loader in the kernel will, however, add a small extra data table
just before .data's content (cf. handling of MAX_SHARED_LIBS in
binfmt_flat.c:load_flat_file).

Now, if .text and .data are in the same segment, directly following each
other in the binary file, but have that extra data table added in the
run-time memory layout, GDB will get very confused when trying to access
items in the now-moved .data section.  Without any kernel (loader) / GDB
changes, the solution is to tell the linker to always put .text and .data
into separate segments, which GDB will handle gracefully then.

     Section to Segment mapping:
      Segment Sections...
       00     .text
       01     .data .eh_frame_hdr .eh_frame .bss

Tested on m68k-uclinux (where the problem occurred) and arm-uclinuxeabi
(no regressions).

2010-02-27  Thomas Schwinge  <thomas@codesourcery.com>

14 years agouse AS_HELP_STRING for all configure options
David McCullough [Wed, 3 Feb 2010 22:34:49 +0000 (22:34 +0000)]
use AS_HELP_STRING for all configure options
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agoThis is needed for Blackfin FLAT's to be processed properly, and apparently
David McCullough [Wed, 3 Feb 2010 22:32:46 +0000 (22:32 +0000)]
This is needed for Blackfin FLAT's to be processed properly, and apparently
some other people have seen similar behavior.

http://lists.uclibc.org/pipermail/uclibc/2009-April/042363.html
http://thread.gmane.org/gmane.linux.hardware.blackfin.toolchain.devel/1121

Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years agoMake varargs debug macros GCC-2.x compatible.
David McCullough [Fri, 22 Jan 2010 01:54:20 +0000 (01:54 +0000)]
Make varargs debug macros GCC-2.x compatible.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 years ago[PATCH] add Blackfin to the README
Greg Ungerer [Wed, 20 Jan 2010 02:28:18 +0000 (02:28 +0000)]
[PATCH] add Blackfin to the README

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agofix option order when invoking children
David McCullough [Mon, 9 Nov 2009 23:59:26 +0000 (23:59 +0000)]
fix option order when invoking children

Poor getopt() implementations as found in many BSD/Darwin systems will
stop processing options after a non-option is encountered.  That means
ld-elf2flt has to be careful to not stick options after non-options when
executing sub children.  In a default setup, it will invoke `elf2flt` with
the output followed by the -a option which subsequently fails:
elf2flt: Can't open '-a': No such file or directory

15 years agofix elf2flt dep generation in out-of-tree builds
David McCullough [Sun, 30 Aug 2009 11:43:03 +0000 (11:43 +0000)]
fix elf2flt dep generation in out-of-tree builds
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agothe "all" target should not be depending on "ld-elf2flt"
David McCullough [Tue, 14 Jul 2009 23:00:33 +0000 (23:00 +0000)]
the "all" target should not be depending on "ld-elf2flt"
anymore as this is handled through the PROG vars.  it isnt a problem
for Linux systems, but when EXEEXT is set, things go boom.

Mike Frysinger <vapier.adi@gmail.com>

15 years agothe Makefile.in still refers to elf2flt.sh.in:
David McCullough [Tue, 14 Jul 2009 14:49:14 +0000 (14:49 +0000)]
the Makefile.in still refers to elf2flt.sh.in:
ld-elf2flt.sh: $(srcdir)/ld-elf2flt.sh.in

that should be:
ld-elf2flt.sh: $(srcdir)/ld-elf2flt.in

the shell script is generated without +x bits, but that is fixed
during the install step ... so probably not a real big problem

Mike Frysinger <vapier.adi@gmail.com>

15 years agoDue to shell portability issues (which is to say shell scripts are not
David McCullough [Sun, 12 Jul 2009 23:28:58 +0000 (23:28 +0000)]
Due to shell portability issues (which is to say shell scripts are not
portable -- think Windows), convert elf2flt to C code.

I've updated this code base to the latest elf2flt tree and actually done
some basic tests -- building the three Blackfin tuples (ELF, FLAT, FDPIC)
and running programs on my Blackfin boards.  This process found errors in
the original implementation as well as some of the cleanups I did.

Signed-off-by: Nathan Sidwell <nathan@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agohandle more strip/verbose options.
David McCullough [Tue, 7 Jul 2009 05:39:06 +0000 (05:39 +0000)]
handle more strip/verbose options.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoUnify the duplicated windows and other system fallback logic in stubs.h
David McCullough [Tue, 7 Jul 2009 04:39:42 +0000 (04:39 +0000)]
Unify the duplicated windows and other system fallback logic in stubs.h
and add some fatal() helper functions to standardize the error output when
falling over.  This way we don't end up with obscure error messages with
no idea what util they are coming from.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agogenerate dependency info automatically
David McCullough [Tue, 7 Jul 2009 00:51:21 +0000 (00:51 +0000)]
generate dependency info automatically
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoThis cleans up the Makefile handling of the different compiler flags such
David McCullough [Tue, 7 Jul 2009 00:49:11 +0000 (00:49 +0000)]
This cleans up the Makefile handling of the different compiler flags such
that it uses standard names across the board as well as unifies the link
method.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoadd more common files to gitignore
David McCullough [Tue, 7 Jul 2009 00:46:52 +0000 (00:46 +0000)]
add more common files to gitignore
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agothe flat.h header uses things like uint32_t but does not pull in the
David McCullough [Mon, 6 Jul 2009 04:45:16 +0000 (04:45 +0000)]
the flat.h header uses things like uint32_t but does not pull in the
appropriate stdint.h header

Mike Frysinger <vapier@gentoo.org>

15 years agoWe renamed all the Blackfin relocs in the toolchain to match other ports
David McCullough [Thu, 4 Jun 2009 23:16:34 +0000 (23:16 +0000)]
We renamed all the Blackfin relocs in the toolchain to match other ports
(all caps and a R_BFIN_ prefix), so update elf2flt accordingly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoRather than putting the `rm` at the end of the script before the normal
David McCullough [Tue, 2 Jun 2009 00:09:46 +0000 (00:09 +0000)]
Rather than putting the `rm` at the end of the script before the normal
exit point, create a trap to automatically delete the script when exiting.
This way the linker script gets cleaned up whenever there is an error as
well.  Otherwise every link invocation that ends in a failure could leave
behind crap.  On my system, i found almost 2 million of these suckers in
my /tmp dir.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoWhen the relocs are larger than 16bits, incorrect values are written when
David McCullough [Sun, 24 May 2009 23:33:48 +0000 (23:33 +0000)]
When the relocs are larger than 16bits, incorrect values are written when
the .H/.L loading are reversed.  Normally this wouldn't happen because the
gcc compiler always outputs in the same order (first hi, then lo).

Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoAdd -u/-U options to control the Blackfin L1 stack flag.
David McCullough [Fri, 22 May 2009 00:22:05 +0000 (00:22 +0000)]
Add -u/-U options to control the Blackfin L1 stack flag.

Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoAdd a .gitignore file
David McCullough [Fri, 22 May 2009 00:20:50 +0000 (00:20 +0000)]
Add a .gitignore file

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoNewer gcc compilers generate some ARM relocation types that we should
Greg Ungerer [Thu, 21 May 2009 07:02:06 +0000 (07:02 +0000)]
Newer gcc compilers generate some ARM relocation types that we should
deal with in elf2flt.

Patch submitted by Erwin Authried <eauth@softsys.co.at>

15 years agoThe option given to AC_ARG_ENABLE() have typos in them -- they use an
David McCullough [Mon, 18 May 2009 22:29:44 +0000 (22:29 +0000)]
The option given to AC_ARG_ENABLE() have typos in them -- they use an
underscore instead of a dash.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoAttached is a patch that updates elf2flt support for microblaze:
David McCullough [Mon, 18 May 2009 22:28:20 +0000 (22:28 +0000)]
Attached is a patch that updates elf2flt support for microblaze:

 * Handling for new reloc type R_MICROBLAZE_32_PCREL_LO (we can just ignore it)
 * remove workarounds for old microblaze linker bugs, fixed in 2.16

Signed-off-by: John Williams <john.williams@petalogix.com>
15 years agoThe header logic for pulling in ELF defines mixes common ELF headers and
David McCullough [Sun, 17 May 2009 23:14:54 +0000 (23:14 +0000)]
The header logic for pulling in ELF defines mixes common ELF headers and
target specific headers.  In the Blackfin case, we always want to pull in
the bfin.h since most of the time, the common ELF headers do not have our
relocation defines.  This fixes building for mingw targets.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoUpdate configure to get the new ctor/dtor option.
David McCullough [Thu, 7 May 2009 23:09:35 +0000 (23:09 +0000)]
Update configure to get the new ctor/dtor option.

15 years agoupdate Blackfin port
David McCullough [Thu, 7 May 2009 06:23:02 +0000 (06:23 +0000)]
update Blackfin port

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoonly print "No relocations" when in verbose mode
David McCullough [Thu, 7 May 2009 06:17:42 +0000 (06:17 +0000)]
only print "No relocations" when in verbose mode

Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoSince the nios2 port is the only one to use the get_gp_value() function,
David McCullough [Thu, 7 May 2009 06:16:36 +0000 (06:16 +0000)]
Since the nios2 port is the only one to use the get_gp_value() function,
stick it behind a TARGET_nios2 ifdef.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoThe FLAT structure is all built on 32bit types, so make sure the elf2flt
David McCullough [Thu, 7 May 2009 06:15:31 +0000 (06:15 +0000)]
The FLAT structure is all built on 32bit types, so make sure the elf2flt
code uses 32bit types rather than long's.  This way we get correct
behavior when the host sizeof(long) is not 32bit as is on all 64bit
systems nowadays.

Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoGCC properly provides CTOR/DTOR END/LIST symbols already via the normal
David McCullough [Thu, 7 May 2009 06:14:27 +0000 (06:14 +0000)]
GCC properly provides CTOR/DTOR END/LIST symbols already via the normal
crtbegin and crtend objects.  Since it's been doing this for a while, add
a configure option to control the manual list found in the elf2flt linker
script and default it to off now.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoOften build systems will use -shared when creating shared libraries, so
David McCullough [Thu, 7 May 2009 03:33:32 +0000 (03:33 +0000)]
Often build systems will use -shared when creating shared libraries, so
don't barf on the flag when we see it.  This makes porting efforts easier.
As a sanity check, make sure we see the -shared-lib-id flag when creating
a shared library.

Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoIf there is no bss section, set bss_vma to the end of data.
David McCullough [Thu, 7 May 2009 03:32:21 +0000 (03:32 +0000)]
If there is no bss section, set bss_vma to the end of data.

Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoNewer versions of gcc (4.3+) may output additional exception tables
David McCullough [Thu, 7 May 2009 03:31:14 +0000 (03:31 +0000)]
Newer versions of gcc (4.3+) may output additional exception tables
sections, so we need to include those as well.

Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoRename elf2flt.ld to elf2flt.ld.in.
David McCullough [Thu, 7 May 2009 01:04:19 +0000 (01:04 +0000)]
Rename elf2flt.ld to elf2flt.ld.in.

15 years agoRe-run autoconf to make sure everything is up to date.
David McCullough [Thu, 7 May 2009 00:02:06 +0000 (00:02 +0000)]
Re-run autoconf to make sure everything is up to date.

15 years agoSome arches (like the Blackfin architecture) have an ABI where all symbols
David McCullough [Wed, 6 May 2009 23:59:01 +0000 (23:59 +0000)]
Some arches (like the Blackfin architecture) have an ABI where all symbols
get a symbol prefix.  In our case, it's an underscore ("_").  So we set the
symbol prefix in the configure script and output it in the linker script and
all relevant files.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoGeneral update for the different DWARF debugging styles gcc may output.
David McCullough [Wed, 6 May 2009 23:40:28 +0000 (23:40 +0000)]
General update for the different DWARF debugging styles gcc may output.
This only adds possible debug sections, so it shouldn't cause any
regressions.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoPT_GNU_STACK markings make no sense with FLAT binaries, so discard the
David McCullough [Wed, 6 May 2009 23:39:42 +0000 (23:39 +0000)]
PT_GNU_STACK markings make no sense with FLAT binaries, so discard the
related section when linking.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agowhitespace cleanup
David McCullough [Wed, 6 May 2009 23:38:22 +0000 (23:38 +0000)]
whitespace cleanup
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
15 years agoWhen compiled with CVS binutils, busybox fails to execute properly.
David McCullough [Thu, 27 Nov 2008 12:20:48 +0000 (12:20 +0000)]
When compiled with CVS binutils, busybox fails to execute properly.
That's because it's using --gc-sections, and the elf2flt linker script
allows the linker to remove parts of the .init and .fini sections.  This
patch fixes it.

Bernd Schmidt <bernds_cb1@t-online.de>

15 years agoKazu Hirata wrote:
David McCullough [Thu, 27 Nov 2008 01:08:04 +0000 (01:08 +0000)]
Kazu Hirata wrote:
> Attached is a patch to fix elf2flt.ld so that C++ programs will link
> successfully.
>
> Nathan Sidwell says:
> nathan@codesourcery.com
>
>   "The problem is the .eh_frame_hdr optimization. firstly that input
>   section was not mentioned in the linker script and secondly, the
>   linker requires .eh_frame_hdr and .eh_frame section in the output,
>   so it can optimize them. I move gcc_except_table out of .data, for
>   consistency."

I've been trying to get CVS binutils up and running on the Blackfin, and
after debugging a C++ link failure I eventually tracked it down to the
elf2flt linker script, and google pointed me at this thread which I'd
completely forgotten in the meantime.  The patch is needed, please apply
to elf2flt.

Bernd Schmidt <bernds_cb1@t-online.de>

15 years agoIt is somewhat common for people to use the -s (strip) option to the
David McCullough [Fri, 21 Nov 2008 11:35:07 +0000 (11:35 +0000)]
It is somewhat common for people to use the -s (strip) option to the
compiler when linking.  Currently this breaks FLAT generation.  There's no
real reason that I can see that we would bother keeping this, so just filter
it out to make compatibility / ease of use nicer.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agoThe Blackfin port uses _current_shared_library_p5_offset_ for the GOT offset
David McCullough [Thu, 6 Nov 2008 03:33:30 +0000 (03:33 +0000)]
The Blackfin port uses _current_shared_library_p5_offset_ for the GOT offset
symbol, and it adjusts it by 1 rather than 4.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agoupdate configure after configure.in changes.
David McCullough [Sun, 2 Nov 2008 23:14:37 +0000 (23:14 +0000)]
update configure after configure.in changes.

16 years agoWe should link against -lc before any of the binutils libs (libiberty/bfd)
David McCullough [Sun, 2 Nov 2008 23:13:45 +0000 (23:13 +0000)]
We should link against -lc before any of the binutils libs (libiberty/bfd)
as those libs provide replacements for some common functions we don't really
care about (like getopt).  Otherwise, if the C library does something wacky
in its API (like renaming symbols), we get a desync where some symbols are
provided by the binutils libs while others are provided by the C library.

For a concrete example, try building elf2flt on OS X 10.5.  Their stupid
headers do this in unistd.h:

int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003");

The resulting elf2flt binaries are incapable of properly parsing any option
given to them.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agowhen debugging a flat loader problem involving relocs, i found it very
David McCullough [Sun, 2 Nov 2008 23:10:52 +0000 (23:10 +0000)]
when debugging a flat loader problem involving relocs, i found it very
useful to compare what the loader was trying to do with what relocs
were actually in the binary

to that end, i add a '-P' flag to flthdr that will dump all the reloc
information found in a flat binary.

Mike Frysinger <vapier.adi@gmail.com>

16 years agoReserve a flag for the blackfin target (FLAT_FLAG_L1STK), no other platform
David McCullough [Wed, 29 Oct 2008 11:38:34 +0000 (11:38 +0000)]
Reserve a flag for the blackfin target (FLAT_FLAG_L1STK),  no other platform
will use it,  but for now we have plenty of bits left and we can always
re-use it later if needed.

16 years agoupdated configure thanks to Atle Nissestad <atle@nissestad.no>
David McCullough [Wed, 11 Jun 2008 13:24:51 +0000 (13:24 +0000)]
updated configure thanks to Atle Nissestad <atle@nissestad.no>

16 years agoI'm lazy and having to set 4 configure options when I could just set 1 is a
David McCullough [Thu, 13 Mar 2008 04:38:28 +0000 (04:38 +0000)]
I'm lazy and having to set 4 configure options when I could just set 1 is a
pain.  So --with-binutils-build-dir allows you to set the base tree of the
compiled binutils directory and will setup reasonable defaults for the flags
(if they haven't already been set):

 --with-libbfd
 --with-libiberty
 --with-bfd-include-dir
 --with-binutils-include-dir

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agoThis patch allows elf2flt/flthdr's compression options to work in a wider
David McCullough [Wed, 27 Feb 2008 11:41:32 +0000 (11:41 +0000)]
This patch allows elf2flt/flthdr's compression options to work in a wider
variety of environments (e.g. under MinGW/Win32), by linking with zlib
rather than by using external gzip/gunzip executables. The cp binary
isn't used any more either, and libiberty's make_temp_file() is used
instead of mkstemp() as a more portable way of creating a temporary file.

Also the compression logic is made somewhat clearer, IMO.

Signed-off-by: Julian Brown <julian@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agoWhen moving the xmalloc changes from the Blackfin elf2flt to the upstream
David McCullough [Sun, 24 Feb 2008 23:17:51 +0000 (23:17 +0000)]
When moving the xmalloc changes from the Blackfin elf2flt to the upstream
elf2flt repo, I accidentally dropped the libiberty.h include.  Not a fatal
error, but having proper prototypes is always a good thing.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agoI hit a random failure in elf2flt (not elf2flt's fault, I was screwing with
David McCullough [Thu, 21 Feb 2008 01:09:05 +0000 (01:09 +0000)]
I hit a random failure in elf2flt (not elf2flt's fault, I was screwing with
ELFs and LMAs/VMAs), but the resulting error message was useless:
malloc: Cannot allocate memory

Since I was executing `...-gcc` at the time, where exactly this error message
was coming from was hard to say.  So instead of using malloc() and then doing
a simple 'perror("malloc"); exit(1);' in the elf2flt.c code, it'd be better
for everyone if we used the xmalloc() funcs from libiberty.  We're already
linking elf2flt against libiberty, so there's no extra headers/libs to link
against.

Now the crash looks like:
bfin-uclinux-elf2flt: out of memory allocating 4221960244 bytes after a total of
 135168 bytes
So much nicer! :)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
16 years agoThis patch fixes two issues which are triggered when compiling for nios2:
David McCullough [Mon, 3 Dec 2007 23:21:01 +0000 (23:21 +0000)]
This patch fixes two issues which are triggered when compiling for nios2:
* Typo in a goto label
* Misplaced switch statement which probably is left from an older revision.

 - Atle

Signed-off-by: Atle Nissestad <atle@nissestad.no>
16 years agoThe patch below adds two additional DWARF2 debug sections from the standard
David McCullough [Tue, 27 Nov 2007 22:53:00 +0000 (22:53 +0000)]
The patch below adds two additional DWARF2 debug sections from the standard
binutils linker-script.
This is required to fix gdb DWARF errors on nios2.

Signed-off-by: Atle Nissestad <atle@nissestad.no>
16 years agoThis patch is required to successfully link against libstdc++ on the Nios2
David McCullough [Tue, 27 Nov 2007 22:51:30 +0000 (22:51 +0000)]
This patch is required to successfully link against libstdc++ on the Nios2
platform.

Signed-off-by: Atle Nissestad <atle@nissestad.no>
Also remove the duplicated data1 section and add the eh_frame_hdr section.
Source of these changes lost (sorry :-)

17 years agothe intl subdir in binutils may redirect some funcs with libintl_* prefixes
David McCullough [Thu, 11 Oct 2007 03:50:51 +0000 (03:50 +0000)]
the intl subdir in binutils may redirect some funcs with libintl_* prefixes
(like building for win32), so the attached patch adds a stub like the
existing one for dcgettect() ... this fixes building of elf2flt for me for
mingw targets

Mike Frysinger <vapier@gentoo.org>

17 years agoAllow for hex/octal/decimal stack specifications using the usual 0xNN,0NN,NN
David McCullough [Mon, 24 Sep 2007 05:11:48 +0000 (05:11 +0000)]
Allow for hex/octal/decimal stack specifications using the usual 0xNN,0NN,NN
notations.

17 years agoThe short_format var isnt used in flthdr.c, so delete it
David McCullough [Mon, 24 Sep 2007 00:36:17 +0000 (00:36 +0000)]
The short_format var isnt used in flthdr.c, so delete it
Mike Frysinger <vapier@gentoo.org>

17 years agolf2flt crashes on Linux/amd64:
Greg Ungerer [Wed, 1 Aug 2007 03:40:12 +0000 (03:40 +0000)]
lf2flt crashes on Linux/amd64:

(gdb)  run  -a -o links -p links.gdb links.gdb
Starting program: /home/stsp/dslinux/toolchain/prefix/bin/arm-linux-elf-elf2flt -a -o links -p links.gdb links.gdb

Program received signal SIGSEGV, Segmentation fault.
_bfd_elf_canonicalize_reloc (abfd=<value optimized out>, section=0x5f6900,
    relptr=0xffffffffa6360010, symbols=<value optimized out>)
    at /home/stsp/dslinux/toolchain/src/binutils-2.17/bfd/elf.c:6367
6367        *relptr++ = tblptr++;
(gdb) bt
#0  _bfd_elf_canonicalize_reloc (abfd=<value optimized out>, section=0x5f6900,
    relptr=0xffffffffa6360010, symbols=<value optimized out>)
    at /home/stsp/dslinux/toolchain/src/binutils-2.17/bfd/elf.c:6367
#1  0x00000000004006dd in output_relocs (abs_bfd=0x5f5570,
    symbols=0x2b30a5e99010, number_of_symbols=16585, n_relocs=0x7fff04c0fe58,
    text=0x2b30a6102010 "", text_len=<value optimized out>, text_vma=0,
    data=0x2b30a627b010 "", data_len=934480, data_vma=1541824,
    rel_bfd=0x5f4400)
    at /home/stsp/dslinux/toolchain/src/elf2flt-20051225/elf2flt.c:587
#2  0x0000000000401180 in main (argc=<value optimized out>,
    argv=<value optimized out>)
    at /home/stsp/dslinux/toolchain/src/elf2flt-20051225/elf2flt.c:1949

The problem seems to be that the one and only call to xmalloc()
in elf2flt.c does not return a valid pointer for some reason.

I'm wondering why xmalloc() is used exactly once in elf2flt.c.
All other heap allocations in elf2flt are done with plain malloc().

The attached patch fixes the segfault by replacing the call to xmalloc()
with a call to malloc(). It also makes elf2flt check for return
values of malloc() calls, providing the equivalent behaviour of
using xmalloc().

Patch submitted by Stefan Sperling <stsp@stsp.name>

17 years agoRe-autconf configure script after Mike Frysinger's recent AC_ERROR
Greg Ungerer [Wed, 3 Jan 2007 03:53:51 +0000 (03:53 +0000)]
Re-autconf configure script after Mike Frysinger's recent AC_ERROR
fix to configure.in.

17 years agoThe proper way to do error message output is with AC_MSG_ERROR() ... patch
Greg Ungerer [Wed, 3 Jan 2007 03:49:47 +0000 (03:49 +0000)]
The proper way to do error message output is with AC_MSG_ERROR() ... patch
attached.

Patch submitted by Mike Frysinger <vapier@gentoo.org>

17 years agothe install program is run with the '-s' option which makes `install` run the
David McCullough [Thu, 23 Nov 2006 22:42:07 +0000 (22:42 +0000)]
the install program is run with the '-s' option which makes `install` run the
host `strip` on the installed binary ... this certainly wont work when
cross-compiling and really, the standard is to leave stripping up to the
people doing the actual install

so attached patch simply drops the -s argument to install

Mike Frysinger <vapier@gentoo.org>

17 years agothe bzero() function has been marked as depreciated for quite sometime in
David McCullough [Tue, 14 Nov 2006 22:20:08 +0000 (22:20 +0000)]
the bzero() function has been marked as depreciated for quite sometime in
favor of using memset() with a value of 0 ... patch attached

Mike Frysinger <vapier@gentoo.org>

18 years agoBefore I delve in the long (sorry) RFC below, I've been taking:
David McCullough [Wed, 13 Sep 2006 00:10:30 +0000 (00:10 +0000)]
Before I delve in the long (sorry) RFC below, I've been taking:

    http://www.ucdot.org/article.pl?sid=03/11/25/1126257&mode=thread

and:

    http://docs.blackfin.uclinux.org/doku.php?id=adding_libraries

as more-or-less definitive descriptions of how shared flat libraries
should be built and used.  Please let me know if they aren't, and if
there's another recipe somewhere.

Anyway, the RFC is about two issues:

  (1) Shared libraries usually have some symbols that are internally
      STB_GLOBAL (because they are shared between more than one input
      object) but which should nevertheless be treated as local to
      the library as a whole; they shouldn't be exported to users
      of the library.  According to the article above, the usual
      way to arrange this is to run:

        objcopy -L <sym1> -L <sym2> ... foo.gdb

      on the linked foo.gdb library.  That certainly works, but
      maintaining the list of symbols can be a bit cumbersome.

      I think it would help a lot if ld-elf2flt automatically localised
      symbols with hidden and internal visibility.  This would allow
      users to localise symbols in the library source code -- via gcc
      attributes or assembly directives -- and would eliminate one
      difference between shared flat libraries and shared ELF libraries.
      If the library's source code hides all the appropriate symbols --
      which the source code for many ELF-leaning libraries do, unless their
      build system relies on something like "local:" directives in version
      scripts -- then no separate -L list is needed.

  (2) If a shared library and a user of a shared library both define
      some symbol foo, you don't get a redefinition warning or error.
      However, if the symbols are a different size, you _do_ get a warning
      about that.

      To me, this seems like the worst of both worlds.  I can see cases
      where the user would want to be told about any redefinition, and
      would want a command-line option to enable that behaviour.  That's
      a separate issue that I'm not tackling here.

      But when redefinitions are silently allowed, warning about changes
      in size seems a little pointless.  Shared flat libraries can't
      really refer back to symbols defined by the user of the library
      (such as the executable); all symbol references are resolved
      when the library is statically linked.  Shared flat libraries
      act a lot like a restricted form of ELF -Bsymbolic libraries.

      Thus having a different size of symbol S in shared library X and
      user Y is very unlikely to be an issue unless the redefinition of
      S is itself an issue.  X is not going to refer directly to Y's
      definition of S.  And if you create, say, a shared C library that
      includes all the C library functions needed by at least one
      program on the system, it's likely that some programs will have
      harmless symbol name clashes.  For example, some programs might be
      written with just standard C in mind, and use symbols that clash
      with a POSIX, GNU or uClibc extension.

      I think it would help if we weakened the exported symbols.  This
      would tell the linker that the symbols are only there if needed,
      and that the user of the library is free to use the symbol for
      something else.  This wouldn't affect the redefinition diagnostic;
      if that diagnostic is ever implemented, it should apply to both
      global and weak symbols, because in both cases we'll have two
      definitions of the same symbol.

Comments?  Does this sound reasonable sane?

In case it does, the patch below implements both (1) and (2).  (1) is
simple with CVS objcopy, which now has a --localize-hidden option:

    http://sources.redhat.com/ml/binutils/2006-06/msg00204.html

Sadly, that option won't appear in an FSF release before 2.18, so I've
provided a fall-back that uses objdump and sed instead.  (2) is easy
with the long-standing --weaken option.

FWIW, the patch has been tested fairly extensively on Coldfire with
shared C and C++ libraries, as well as with ad-hoc libraries.  No
post-processing of these libraries was needed: you could just link with
ld-elf2flt and use the output directly.

I've tested both the --localize-hidden and fallback versions.

Richard

Signed-off-by: Richard Sandiford <richard@codesourcery.com>
18 years agoThis patch adds elf2flt support for prioritised constructors and destructors,
David McCullough [Fri, 21 Jul 2006 13:11:04 +0000 (13:11 +0000)]
This patch adds elf2flt support for prioritised constructors and destructors,
but only when --enable-emit-relocs is in effect.

GCC puts prioritised constructors and destructors in special .ctor.N
and .dtor.N sections (where N encodes the priority).  The constructors
and destructors in these sections have a lower priority than those
in the default .ctor and .dtor sections.  However, we need to treat
the crtbegin.o's and crtend.o's sections specially; crtbegin.o's .[cd]tor
sections must come before all the other .[cd]tor* contents and crtend.o's
.[cd]tor sections must come after all other contents.

In --disable-emit-relocs links, it wasn't possible to treat crtbegin.o
and crtend.o specially.  ld-elf2flt would do:

                ld -r -o foo.elf2flt ...input objects...
                    |                               |
            ld -r -o foo.elf foo.elf2flt -T script  |
                                                    |
                                   ld -o foo.gdb foo.elf2flt -T script

so all the input .[cd]tor sections would already be lumped together by the
time the script was used.  This isn't a problem for --enable-emit-relocs as
it only links once.

The patch copies the [cd]tor support from the standard binutils linker
script.  The question is: should the new lines be used unconditionally,
or only when --enable-emit-relocs is in effect?

We could use the new lines for --disable-emit-relocs without breaking
programs that don't use prioritised [cd]tors.  However, it would be a user
interface regression for programs that _do_ use them.  At the moment,
if you try to use prioritised [cd]tors with --disable-emit-relocs,
you get a linker error like this:

   error: no memory region specified for loadable section `.ctors.60535'

With the new lines, the link would silently succeed, and you'd get a
runtime failure instead.  I've therefore guarded the lines with
"SINGLE_LINK:", a bit like the "W_RODAT" stuff that's already there.

Tested on Coldfire, with both --enable-emit-relocs and
--disable-emit-relocs.  It fixes the GCC ecos.exp tests.
Please install if OK.

Richard

Signed-off-by: Richard Sandiford <richard@codesourcery.com>
18 years agoUse the emit-relocs options by default unless the user has configured
David McCullough [Mon, 10 Jul 2006 22:23:46 +0000 (22:23 +0000)]
Use the emit-relocs options by default unless the user has configured
it to do otherwise.

Signed-off-by: Richard Sandiford <richard@codesourcery.com>
18 years agoelf2flt.c (output_relocs) <use_resolved> [TARGET_arm]:
David McCullough [Mon, 10 Jul 2006 22:19:10 +0000 (22:19 +0000)]
elf2flt.c (output_relocs) <use_resolved> [TARGET_arm]:
Add R_ARM_THM_PC11, which does not need a relocation.

Shaun Jackman  <sjackman@gmail.com>

18 years agoThis patch adds m68k support for elf2flt -a. I've tested it with
Greg Ungerer [Mon, 10 Jul 2006 06:00:41 +0000 (06:00 +0000)]
This patch adds m68k support for elf2flt -a.  I've tested it with
load-to-RAM, -msep-data PIC-with-GOT and -mshared-library PIC-with-GOT.

Like ARM, but unlike V850, the new code errors out on relocs it doesn't
understand, rather than assuming that they're 32-bit fields.

It seems likely that every port that supports -a will want to print the
"reloc type not supported in this context" message; we've got two copies
already, and m68k would add a third.  I've therefore moved the v850
"bad_v850_reloc_err:" code outside the #ifdef and renamed the label to
the more neutral "bad_resolved_reloc:".  I've also changed the ARM code
to use this now-common code instead of its own copy.

In a similar vein, I've changed the default 32-bit field handling
so that it is the target of a new label, "good_32bit_resolved_reloc:".
The generic and v850 code can then jump to this code in their default
cases, while m68k can jump to it for R_68K_32 relocs.

The patch was written before Shaun Jackman made -p and -a work together:

    http://mailman.uclinux.org/pipermail/uclinux-dev/2006-June/039029.html

I'd been using this hunk too, but as well as guarding:

    q->address += got_size;

with "!use_resolved", I'd guarded the calculation of got_size itself,
as the value isn't otherwise used.  I've kept this additional check
in the attached patch.  Please apply if OK.

Signed-off-by: Richard Sandiford <richard@codesourcery.com>
18 years ago * elf2flt.c (output_relocs) <use_resolved> [TARGET_arm]: Add
Greg Ungerer [Mon, 3 Jul 2006 05:50:10 +0000 (05:50 +0000)]
* elf2flt.c (output_relocs) <use_resolved> [TARGET_arm]: Add
    R_ARM_REL32, which does not need a relocation.

Patch submitted by Shaun Jackman <sjackman@gmail.com>

18 years agoSupport the -a (use_resolved) option for TARGET_arm.
David McCullough [Mon, 26 Jun 2006 22:18:15 +0000 (22:18 +0000)]
Support the -a (use_resolved) option for TARGET_arm.
Shaun Jackman <sjackman@gmail.com>

18 years agoWe've eliminated the use of the relocation stack from the Blackfin
David McCullough [Mon, 19 Jun 2006 22:00:41 +0000 (22:00 +0000)]
We've eliminated the use of the relocation stack from the Blackfin
toolchain.  That means that the corresponding code in elf2flt can go
away, which is done by the patch below.

Bernd Schmidt <bernds_cb1@t-online.de>

18 years agoNewly autoconf generated configure script. It was out-of-date relative
Greg Ungerer [Thu, 15 Jun 2006 01:48:46 +0000 (01:48 +0000)]
Newly autoconf generated configure script. It was out-of-date relative
to the current configure.in. It didn't properly process
@binutils_ldscript_dir@, and that meant it was not properly set
in the ld-elf2flt.in/elf2flt.ld processing.