OSDN Git Service
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
David McCullough [Thu, 7 May 2009 23:09:35 +0000 (23:09 +0000)]
Update configure to get the new ctor/dtor option.
David McCullough [Thu, 7 May 2009 06:23:02 +0000 (06:23 +0000)]
update Blackfin port
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
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>
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>
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>
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>
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>
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>
David McCullough [Thu, 7 May 2009 01:04:19 +0000 (01:04 +0000)]
Rename elf2flt.ld to elf2flt.ld.in.
David McCullough [Thu, 7 May 2009 00:02:06 +0000 (00:02 +0000)]
Re-run autoconf to make sure everything is up to date.
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>
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>
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>
David McCullough [Wed, 6 May 2009 23:38:22 +0000 (23:38 +0000)]
whitespace cleanup
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
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>
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>
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>
David McCullough [Sun, 2 Nov 2008 23:14:37 +0000 (23:14 +0000)]
update configure after configure.in changes.
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>
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>
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.
David McCullough [Wed, 11 Jun 2008 13:24:51 +0000 (13:24 +0000)]
updated configure thanks to Atle Nissestad <atle@nissestad.no>
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>
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>
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>
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>
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>
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>
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 :-)
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>
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.
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
David McCullough [Tue, 23 May 2006 22:28:31 +0000 (22:28 +0000)]
The patch below teaches elf2flt to handle R_68K_PC16 relocs.
Our immediate need for this was to deal with relocs for uClibc's
libc/sysdeps/linux/m68k/clone.S, which has "bcc.w __syscall_error"
instructions. It might be argued that clone.S should be using jbcc
instead, in case __syscall_error ends up too far away. But even if
that's true, elf2flt should still support such branches in cases
whether the user _knows_ that the target is within range.
So I think elf2flt should be patched either way.
We've been using this patch for a while now without problems.
Please install if OK.
Richard
Signed-off-by: Richard Sandiford <richard@codesourcery.com>
David McCullough [Thu, 6 Apr 2006 00:37:45 +0000 (00:37 +0000)]
The current elf2flt.ld forgets to allow to put `gnu.linkonce.r*' sections
in the read-only data segment.
Philippe De Muyter <phdm@macqel.be>
David McCullough [Mon, 3 Apr 2006 02:58:44 +0000 (02:58 +0000)]
Add the "b" back to files opens for WIN32 builds as I am fairly sure it was
required.
Fix the remain rb and wb cases that were missed.
Greg Ungerer [Mon, 3 Apr 2006 00:24:56 +0000 (00:24 +0000)]
Changed the mode argument for all the popen() calls to be just "w",
instead of "wb". According to the Linux manual page posix implementations
must accept only "r" or "w", no other characters. And you will get a
return error with EINVAL with modern version og glibc if this is not
the case.
It may well be that this is fine for CYGWIN too, someone needs to
test and report.
Calls to fopen and the like are unchanged, and they certainly do
support the "b" mode specifier.
David McCullough [Mon, 3 Apr 2006 00:06:38 +0000 (00:06 +0000)]
Whee. What a most entertaining bug.
For some (unfathomable) reason, the flat loader in the kernel likes to
use network (big endian) byte order, but only sometimes. In particular,
its assumptions about relocation byte order depend on whether the
executable uses ID shared libraries or not.
It took me most of today to figure out why the kernel was trying to
relocate something at address 0x94160000, until I noticed that that's
the byteswapped version of 0x1694, and further noticed that it was
omitting a byteswap due to the flag Has-PIC-GOT in the flat header.
So, why is that flag set? After all, opreport wasn't compiled with
-mid-shared-library or anything.
It turns out that elf2flt sets that flag if grepping the executable for
GLOBAL_OFFSET_TABLE succeeds. That's a reasonable thing to do, except
when we link an executable against libbfd.a - which contains
GLOBAL_OFFSET_TABLE not as a symbol, but as a string, as it needs to
produce the symbol in linker output files.
Changing elf2flt to grep nm output, rather than the executable directly,
fixes the problem. So, in the end it turns out this wasn't related to
the
20030928 failure at all...
Bernd Schmidt <bernds_cb1@t-online.de>
David McCullough [Thu, 23 Mar 2006 23:06:49 +0000 (23:06 +0000)]
This patch adds support for .preinit_array, .init_array and .fini_array
to the elf2flt linker script. This seems useful in itself, and is
actually required for recent versions of uclibc, where UCLIBC_CTOR_DTOR=y
depends on the associated array symbols being defined.
Tested on m68k-uclinux using the gcc and g++ DejaGNU testsuites. I also
ran some tests by hand to make sure that callbacks in the array sections
were being called at the right time. Please install if OK.
Richard
Signed-off-by: Richard Sandiford <richard@codesourcery.com>
David McCullough [Wed, 22 Feb 2006 01:29:27 +0000 (01:29 +0000)]
Hello,
the following trivial patch is required to build elf2flt
on Darwin. Weirdly, static compilation is intentionally
unsupported by Apple for better compatibility:
http://developer.apple.com/qa/qa2001/qa1118.html
As elf2flt binaries are usually shipped along with other
dynamic binaries such as gcc and gdb, we don't loose
anything on Linux.
I'd commit it myself, but I can't access the CVS server
right now.
Bernardo Innocenti <bernie@develer.com>
David McCullough [Wed, 1 Feb 2006 22:34:46 +0000 (22:34 +0000)]
This patch allows cross-compilation of elf2flt for MinGW hosts when a
non-MinGW build system is in use. By using uname, there is currently an
assumption in 'Makefile.in' that (build system) == (host system), which
isn't necessarily the case in a Canadian cross environment. (At
CodeSourcery we use Linux for building our MinGW-hosted toolchains, some
of which will soon include elf2flt).
Julian Brown <julian@codesourcery.com>
David McCullough [Tue, 17 Jan 2006 23:12:08 +0000 (23:12 +0000)]
Patch to add configure option:
--with-binutils-ldscript-dir
to allow the user to change the location of the elf2flt.ld script.
Mike Frysinger <vapier@gentoo.org>
Greg Ungerer [Fri, 13 Jan 2006 06:08:01 +0000 (06:08 +0000)]
seems my previous attempt at updating the current elf2flt code with nios
relocations was slightly wrong ... the code needs to be moved down a few
hundred lines :)
Patch submitted by Mike Frysinger <vapier@gentoo.org>
David McCullough [Wed, 11 Jan 2006 03:39:16 +0000 (03:39 +0000)]
nios/nios2 support by Wentao Xu <wentao@microtronix.com>
cleaned up for inclusion by Mike Frysinger <vapier@gentoo.org>
David McCullough [Wed, 28 Sep 2005 05:26:02 +0000 (05:26 +0000)]
Hi,
I'm the maintainer of a windows hosted arm-elf gcc toolchain used mostly
for homebrew console development. One of my users recently asked if I
could have a look a getting elf2flt to build under mingw/msys to help
with his uclinux Nintendo DS port. I've attached a patch containing the
changes I made to the source in CVS, thought it might be useful.
2005-09-25 Dave Murphy <davem@devkitpro.org>
* Makefile.in: add ws2_32 library when building from msys shell.
* cygwin-elf.h: On mingw.include stdint.h and add extra typedefs
* elf2flt.c: Include cygwin-elf.h on mingw too.
* flthdr.c: For mingw use winsock2.h for internet consts & structs ,
use mktemp instead of mkstemp
Dave
David McCullough [Thu, 25 Aug 2005 02:19:42 +0000 (02:19 +0000)]
Blackfin support merged in by Bernd Schmidt <bernds_cb1@t-online.de>
David McCullough [Mon, 1 Aug 2005 00:02:33 +0000 (00:02 +0000)]
Change all file format related unsigned longs to uint32_t, so that 64 bits
hosts can build this code correctly, plus a little bit of Blackfin code.
Most of the changes provided Bernd Schmidt <bernds_cb1 at t-online.de>
David McCullough [Fri, 15 Jul 2005 10:33:32 +0000 (10:33 +0000)]
A new config.sub with blackfin support
Bernd Schmidt <bernds_cb1@t-online.de>
David McCullough [Wed, 6 Jul 2005 23:00:20 +0000 (23:00 +0000)]
Small spelling fixup from Dylan Griffiths.
John Williams [Tue, 3 May 2005 23:26:11 +0000 (23:26 +0000)]
Tweaked Makefile.in so that post-configured Makefile tests for a Cygwin build
environment, and if detected, explicitly adjusts the link order so that
libcygwin links *before* libiberty.a. This gets around a Cygwin problem with
getopt()'s optind/optarg symbols. See, for example:
http://sources.redhat.com/ml/cygwin/2004-04/msg01179.html
Also tweaked cygwin-elf.h and elf2flt.c so that Cygwin builds for MicroBlaze
target work as expected.
Patch sumbitted by John Williams <jwilliams@itee.uq.edu.au>
John Williams [Mon, 18 Apr 2005 22:00:48 +0000 (22:00 +0000)]
Explicit assignment of elf2flt package under GPL v2.0.
Bernardo Innocenti [Wed, 16 Mar 2005 03:26:26 +0000 (03:26 +0000)]
Add missing headers.
Patch submitted by Bernardo Innocenti <bernie@develer.com>.
Bernardo Innocenti [Wed, 23 Feb 2005 01:33:26 +0000 (01:33 +0000)]
Build elf2flt with headers from binutils 2.15.94+.
Should still work with older versions of binutils.
Patch submitted by Bernardo Innocenti <bernie@develer.com>.
Bernardo Innocenti [Wed, 23 Feb 2005 01:31:04 +0000 (01:31 +0000)]
Cygwin fixes.
Patch submitted by Stig Petter Olsrød <stigpo@users.sourceforge.net>.
John Williams [Mon, 8 Nov 2004 00:25:31 +0000 (00:25 +0000)]
Add support for win32 (non-cygwin) builds of elf2flt
Fix minor typo in error message
Patch submitted by Scott Thibault <thibault@gmvhdl.com>
Yoshinori Sato [Thu, 28 Oct 2004 16:54:25 +0000 (16:54 +0000)]
h8/300 forbid relocation of absolute symbol
David McCullough [Thu, 13 May 2004 00:45:07 +0000 (00:45 +0000)]
- add target h8300h
- shared flat binary support for h8
Yoshinori Sato <ysato@users.sourceforge.jp>
David McCullough [Tue, 23 Mar 2004 04:00:15 +0000 (04:00 +0000)]
Use headers direct from binutils
Patch also includes a horrible kludge to get around some wierdness in the
elf files produced by mb-ld.
John Williams <jwilliams@itee.uq.edu.au>
David McCullough [Fri, 19 Mar 2004 00:17:18 +0000 (00:17 +0000)]
A small patch to ld-elf2flt.in, that lets an elf2flt-ified toolchain run
from a directory other than that specifed in the original ./configure.
Helpful if you distribute toolchains and can't control where people
install them! :) Also helpful if you are testing toolchains and need to
move them around after the elf2flt "make install".
John Williams <jwilliams@itee.uq.edu.au>
Greg Ungerer [Tue, 9 Mar 2004 04:49:56 +0000 (04:49 +0000)]
Somehow the microblaze support in elf2flt/config.sub was removed in the last revision (1.4 -> 1.5).
Attached patch restores it.
Submitted by John Williams <jwilliams@itee.uq.edu.au>.
David McCullough [Tue, 10 Feb 2004 00:22:19 +0000 (00:22 +0000)]
When the linker "-v" flag is passed, turn on shell debugging to show what
we are doing.