OSDev.org
https://forum.osdev.org/

Problem Making Cross Binutils - Undefined Symbol
https://forum.osdev.org/viewtopic.php?f=1&t=31397
Page 1 of 1

Author:  cartmo [ Thu Mar 02, 2017 9:56 am ]
Post subject:  Problem Making Cross Binutils - Undefined Symbol

Hi,

I'm trying to make a cross compiler for the arm-none-eabi target, but following the directions in the tutorial results in this error when making binutils:

Code:
gcc -g -O2   -static-libstdc++ -static-libgcc -Wl,--stack,12582912   \
        -o gdb.exe gdb.o arm-tdep.o ser-base.o ser-unix.o ser-pipe.o ser-tcp.o  remote.o dcache.o tracepoint.o ax-general.o ax-gdb.o remote-fileio.o remote-notif.o ctf.o tracefile.o tracefile-tfile.o remote-sim.o cli-dump.o cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-logging.o cli-interp.o cli-utils.o mi-out.o mi-console.o mi-cmds.o mi-cmd-catch.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o mi-cmd-target.o mi-cmd-info.o mi-interp.o mi-main.o mi-parse.o mi-getopt.o tui-command.o tui-data.o tui-disasm.o tui-file.o tui-hooks.o tui-interp.o tui-io.o tui-layout.o tui-out.o tui-regs.o tui-source.o tui-stack.o tui-win.o tui-windata.o tui-wingeneral.o tui-winsource.o tui.o python.o guile.o elfread.o stap-probe.o posix-hdep.o c-exp.o cp-name-parser.o ada-exp.o jv-exp.o d-exp.o f-exp.o go-exp.o m2-exp.o p-exp.o version.o annotate.o addrmap.o auto-load.o auxv.o agent.o bfd-target.o blockframe.o breakpoint.o break-catch-sig.o break-catch-throw.o findvar.o regcache.o cleanups.o charset.o continuations.o corelow.o disasm.o dummy-frame.o dfp.o source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o block.o symtab.o psymtab.o symfile.o symfile-debug.o symmisc.o linespec.o dictionary.o infcall.o infcmd.o infrun.o expprint.o environ.o stack.o thread.o exceptions.o extension.o filesystem.o filestuff.o inf-child.o interps.o minidebug.o main.o macrotab.o macrocmd.o macroexp.o macroscope.o mi-common.o event-loop.o event-top.o inf-loop.o completer.o gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o gdb_obstack.o osabi.o copying.o memattr.o mem-break.o target.o target-dcache.o parse.o language.o build-id.o buildsym.o findcmd.o std-regs.o signals.o exec.o reverse.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o dbxread.o coffread.o coff-pe-read.o dwarf2read.o mipsread.o stabsread.o corefile.o dwarf2expr.o dwarf2loc.o dwarf2-frame.o dwarf2-frame-tailcall.o ada-lang.o c-lang.o d-lang.o f-lang.o objc-lang.o ada-tasks.o ada-varobj.o c-varobj.o ui-out.o cli-out.o varobj.o vec.o go-lang.o go-valprint.o go-typeprint.o jv-lang.o jv-valprint.o jv-typeprint.o jv-varobj.o m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o sentinel-frame.o complaints.o typeprint.o ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o ada-valprint.o c-valprint.o cp-valprint.o d-valprint.o f-valprint.o m2-valprint.o serial.o mdebugread.o top.o utils.o ui-file.o user-regs.o frame.o frame-unwind.o doublest.o frame-base.o inline-frame.o gnu-v2-abi.o gnu-v3-abi.o cp-abi.o cp-support.o cp-namespace.o d-support.o reggroups.o trad-frame.o tramp-frame.o solib.o solib-target.o prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o xml-utils.o target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o inferior.o osdata.o gdb_usleep.o record.o record-full.o gcore.o gdb_vecs.o jit.o progspace.o skip.o probe.o common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o format.o registry.o btrace.o record-btrace.o waitstatus.o print-utils.o rsp-low.o errors.o common-debug.o debug.o common-exceptions.o inflow.o    init.o \
          ../sim/arm/libsim.a ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -lncurses -lm   -liconv    ../libiberty/libiberty.a -luser32 build-gnulib/import/libgnu.a
ada-exp.o: In function `ada_parse_internal':
/usr/src/build-binutilsarm/gdb/ada-exp.c:1637: undefined reference to `ada_lex'
/usr/src/build-binutilsarm/gdb/ada-exp.c:1637:(.text+0x247d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `ada_lex'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1347: gdb.exe] Error 1
make[2]: Leaving directory '/usr/src/build-binutilsarm/gdb'
make[1]: *** [Makefile:9962: all-gdb] Error 2
make[1]: Leaving directory '/usr/src/build-binutilsarm'
make: *** [Makefile:836: all] Error 2


I can get a working binutils by passing --disable-gdb to the configure script, which was good enough for me to begin with, but I'm at the stage where a working debugger would be handy and so I'd like to solve this.

Any ideas what I could be doing wrong?

Author:  kzinti [ Thu Mar 02, 2017 10:06 am ]
Post subject:  Re: Problem Making Cross Binutils - Undefined Symbol

If all you want is get your cross-compiler and move on, you can try using my Makefile here:

https://github.com/kiznit/build-gcc-and-binutils

Simply type:

Code:
make arm-none-eabi


If you get errors, it likely means you are missing some prerequesite librairies.

PREFIX is set to "$(HOME)/opt/cross" in gcc.mk, change it to what you want / need.

Author:  cartmo [ Thu Mar 02, 2017 12:08 pm ]
Post subject:  Re: Problem Making Cross Binutils - Undefined Symbol

Thanks kzinti,

Should also have mentioned that I'm doing this under cygwin. I had a look at your makefile though and the sequence of commands seems to be exactly what I was using.

Author:  joeking [ Mon Mar 27, 2017 5:23 pm ]
Post subject:  Re: Problem Making Cross Binutils - Undefined Symbol

Did you get it working under Cygwin?

I found that the current flex in cygwin with 2.6.3, while I was able to build binutils in mingw with flex 2.5.35

GDB depends on using #define to rename a bunch of yy* symbols, including renaming yylex to ada_lex.
But, with flex 2.6.3 it emits #defines that override this attempt by GDB.
(See the generated ada-lex.c).

Anyways, add "--prefix=ada_" to the FLEX command line
binutils\gdb\Makefile.in
in the .l.c: rule (line 1889)

was:
$(FLEX) -o$@ $< && \
change to:
$(FLEX) -o$@ --prefix=ada_ $< && \

Re-configure and now building GDB works (in cygwin)!

I'm assuming this is really a compatibility problem with the new version of flex and not specifically with Cygwin.

Author:  dozniak [ Tue Mar 28, 2017 2:02 am ]
Post subject:  Re: Problem Making Cross Binutils - Undefined Symbol

Why do you need Ada?

Code:
--enable-languages=c,c++
should cover 146% of your needs

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/