Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAA5faEho0UcE9RpemRKcfXictb+5CO7zzDBh6yu0xj=3F3tfQ@mail.gmail.com>
Date: Tue, 18 Jun 2019 15:54:40 -0700
From: Reinoud Koornstra <reinoudkoornstra@...il.com>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com
Subject: Re: where to find musl-gcc wrapper script

On Tue, Jun 18, 2019 at 2:58 PM Rich Felker <dalias@...c.org> wrote:
>
> On Tue, Jun 18, 2019 at 02:49:17PM -0700, Reinoud Koornstra wrote:
> > On Tue, Jun 18, 2019 at 2:37 PM Rich Felker <dalias@...c.org> wrote:
> > >
> > > On Tue, Jun 18, 2019 at 02:19:06PM -0700, Reinoud Koornstra wrote:
> > > > I noticed that the -static gives me some weird stuff. If I use glibc
> > > > to compile gdb and then rerun the compile command with static I do get
> > > > to see it's a statically linked binary. It'll end up with warnings,
> > > > but ...
> > > > gdb compiles fine with musl as well. So after compiling i see:
> > > > ELF 32-bit executable, ARM, EABI5 version 1 (SYSV). dynamically
> > > > linked, interpreter /lib/ld-musl-armhf.so.1
> > > > When I add -static to the arm-linux-musleabihf-g++ command it compiles
> > > > seemingly fine as well.
> > > > However when i run file again over this I see:
> > > > ELF 32-bit executable, ARM, EABI5 version 1 (SYSV). dynamically
> > > > linked, interpreter, /usr/lib/ld.so.1 ....
> > > > So adding -static didn't seem to have the desired effect, it also all
> > > > over sudden showed a different interpreter.
> > > > Any ideas?
> > >
> > > What commands did you use to build musl-cross-make? Any config.mak
> > > file? What options did you use when linking?
> >
> > in the config.mak for musl-cross-make I used:
> > TARGET = arm-linux-musleabihf
> > OUTPUT = /home/libnl/MUSL-ARM32
> >
> > The rest I left default.
> > To configure gdb-8.3 i used:
> > Then I added OUTPUT to my path: PATH=/home/libnl/MUSL-ARM32/bin:$PATH
> > I configured gdb with:
> > CC=arm-linux-musleabihf-gcc CXX=arm-linux-musleabihf-g++
> > CFLAGS="-I/home/libnl/MUSL-ARM32/include"
> > LDFLAGS="-L/home/libnl/MUSL-ARM32/lib" ./configure --enable-static
> > --host=arm-linux-musleabihf --target=arm-linux-musleabihf
> > --build=x86_64-ubuntu-linux
> >
> > after this I used make.
>
> Where is -static? I don't think gdb offers a way to build
> static-linked; you need to hack it in by putting -static and --static
> (both to trick libtool) in the LDFLAGS.
>
> On top of that, and I think this is your actual problem, I'm pretty
> sure there's a bug in gdb's build process that breaks static linking
> by adding --export-dynamic or --dynamic-list to the link command line,
> which ld then interprets as meaning it should behave like it's dynamic
> linking. Arguably this is actually a bug in gcc that it lets bad
> options get through to the linker when this happens, but the easiest
> way to fix it is patching it out of gdb's makefile after running
> configure. (Alternatively you could patch out the stuff in configure
> that adds it.)

Indeed, gdb doesn't support that natively, but I did follow your advice.
I make a log file of the build, after the build I took a look and in
the gdb directory it does:

arm-linux-musleabihf-g++ -g -O2 -static-libstdc++ -static-libgcc
-L/home/libnl/MUSL-ARM32/lib      -o gdb gdb.o aarch32-linux-nat.o
ada-exp.o ada-lang.o ada-tasks.o ada-typeprint.o ada-valprint.o
ada-varobj.o addrmap.o agent.o annotate.o arch-utils.o
arch/arm-get-next-pcs.o arch/arm-linux.o arch/arm.o arm-linux-nat.o
arm-linux-tdep.o arm-tdep.o auto-load.o auxv.o ax-gdb.o ax-general.o
bcache.o bfd-target.o block.o blockframe.o break-catch-sig.o
break-catch-syscall.o break-catch-throw.o breakpoint.o btrace.o
build-id.o buildsym-legacy.o buildsym.o c-exp.o c-lang.o c-typeprint.o
c-valprint.o c-varobj.o charset.o cli-out.o cli/cli-cmds.o
cli/cli-decode.o cli/cli-dump.o cli/cli-interp.o cli/cli-logging.o
cli/cli-script.o cli/cli-setshow.o cli/cli-style.o cli/cli-utils.o
coff-pe-read.o coffread.o common/agent.o common/btrace-common.o
common/buffer.o common/cleanups.o common/common-debug.o
common/common-exceptions.o common/common-regcache.o
common/common-utils.o common/environ.o common/errors.o common/fileio.o
common/filestuff.o common/format.o common/gdb_tilde_expand.o
common/gdb_vecs.o common/job-control.o common/netstuff.o
common/new-op.o common/pathstuff.o common/posix-strerror.o
common/print-utils.o common/ptid.o common/rsp-low.o
common/run-time-clock.o common/scoped_mmap.o
common/signals-state-save-restore.o common/signals.o common/tdesc.o
common/vec.o common/xml-utils.o compile/compile-c-support.o
compile/compile-c-symbols.o compile/compile-c-types.o
compile/compile-cplus-symbols.o compile/compile-cplus-types.o
compile/compile-loc2c.o compile/compile-object-load.o
compile/compile-object-run.o compile/compile.o complaints.o
completer.o continuations.o copying.o corefile.o corelow.o cp-abi.o
cp-name-parser.o cp-namespace.o cp-support.o cp-valprint.o ctf.o
d-exp.o d-lang.o d-namespace.o d-valprint.o dbxread.o dcache.o debug.o
demangle.o dictionary.o disasm-selftests.o disasm.o dtrace-probe.o
dummy-frame.o dwarf-index-cache.o dwarf-index-common.o
dwarf-index-write.o dwarf2-frame-tailcall.o dwarf2-frame.o
dwarf2expr.o dwarf2loc.o dwarf2read.o elfread.o eval.o event-loop.o
event-top.o exceptions.o exec.o expprint.o extension.o f-exp.o
f-lang.o f-typeprint.o f-valprint.o filename-seen-cache.o filesystem.o
findcmd.o findvar.o fork-child.o frame-base.o frame-unwind.o frame.o
gcore.o gdb-dlfcn.o gdb_bfd.o gdb_obstack.o gdb_regex.o gdb_usleep.o
gdbarch-selftests.o gdbarch.o gdbtypes.o glibc-tdep.o gnu-v2-abi.o
gnu-v3-abi.o go-exp.o go-lang.o go-typeprint.o go-valprint.o
guile/guile.o inf-child.o inf-loop.o inf-ptrace.o infcall.o infcmd.o
inferior.o inflow.o infrun.o inline-frame.o interps.o jit.o language.o
linespec.o linux-fork.o linux-nat.o linux-record.o linux-tdep.o
linux-thread-db.o location.o m2-exp.o m2-lang.o m2-typeprint.o
m2-valprint.o macrocmd.o macroexp.o macroscope.o macrotab.o main.o
maint.o mdebugread.o mem-break.o memattr.o memory-map.o memrange.o
mi/mi-cmd-break.o mi/mi-cmd-catch.o mi/mi-cmd-disas.o mi/mi-cmd-env.o
mi/mi-cmd-file.o mi/mi-cmd-info.o mi/mi-cmd-stack.o mi/mi-cmd-target.o
mi/mi-cmd-var.o mi/mi-cmds.o mi/mi-common.o mi/mi-console.o
mi/mi-getopt.o mi/mi-interp.o mi/mi-main.o mi/mi-out.o mi/mi-parse.o
mi/mi-symbol-cmds.o minidebug.o minsyms.o mipsread.o namespace.o
nat/fork-inferior.o nat/linux-namespaces.o nat/linux-osdata.o
nat/linux-personality.o nat/linux-procfs.o nat/linux-ptrace.o
nat/linux-waitpid.o objc-lang.o objfiles.o observable.o opencl-lang.o
osabi.o osdata.o p-exp.o p-lang.o p-typeprint.o p-valprint.o parse.o
posix-hdep.o printcmd.o probe.o proc-service.o
process-stratum-target.o producer.o progspace-and-thread.o progspace.o
prologue-value.o psymtab.o python/python.o record-btrace.o
record-full.o record.o regcache-dump.o regcache.o reggroups.o
registry.o remote-fileio.o remote-notif.o remote.o reverse.o
rust-exp.o rust-lang.o sentinel-frame.o ser-base.o ser-event.o
ser-pipe.o ser-tcp.o ser-uds.o ser-unix.o serial.o skip.o solib-svr4.o
solib-target.o solib.o source-cache.o source.o stabsread.o stack.o
stap-probe.o std-regs.o stub-termcap.o symfile-debug.o symfile-mem.o
symfile.o
symmisc.o symtab.o target-dcache.o target-descriptions.o
target-float.o target-memory.o target.o target/waitstatus.o
test-target.o thread-iter.o thread.o tid-parse.o top.o
tracefile-tfile.o tracefile.o tracepoint.o trad-frame.o tramp-frame.o
typeprint.o ui-file.o ui-out.o ui-style.o user-regs.o utils.o
valarith.o valops.o valprint.o value.o varobj.o version.o
xml-builtin.o xml-support.o xml-syscall.o xml-tdesc.o init.o
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a
-L./../zlib -lz ./../intl/libintl.a ../libiberty/libiberty.a
../libdecnumber/libdecnumber.a   -lm     ../libiberty/libiberty.a
build-gnulib/import/libgnu.a    -ldl
-Wl,--dynamic-list=./proc-service.list

So I changed this now to the follow, omitting the --dynamic-list

arm-linux-musleabihf-g++ -static -g -O2 -static-libstdc++
-static-libgcc -L/home/libnl/MUSL-ARM32/lib      -o gdb gdb.o
aarch32-linux-nat.o ada-exp.o ada-lang.o ada-tasks.o ada-typeprint.o
ada-valprint.o ada-varobj.o addrmap.o agent.o annotate.o arch-utils.o
arch/arm-get-next-pcs.o arch/arm-linux.o arch/arm.o arm-linux-nat.o
arm-linux-tdep.o arm-tdep.o auto-load.o auxv.o ax-gdb.o ax-general.o
bcache.o bfd-target.o block.o blockframe.o break-catch-sig.o
break-catch-syscall.o break-catch-throw.o breakpoint.o btrace.o
build-id.o buildsym-legacy.o buildsym.o c-exp.o c-lang.o c-typeprint.o
c-valprint.o c-varobj.o charset.o cli-out.o cli/cli-cmds.o
cli/cli-decode.o cli/cli-dump.o cli/cli-interp.o cli/cli-logging.o
cli/cli-script.o cli/cli-setshow.o cli/cli-style.o cli/cli-utils.o
coff-pe-read.o coffread.o common/agent.o common/btrace-common.o
common/buffer.o common/cleanups.o common/common-debug.o
common/common-exceptions.o common/common-regcache.o
common/common-utils.o common/environ.o common/errors.o common/fileio.o
common/filestuff.o common/format.o common/gdb_tilde_expand.o
common/gdb_vecs.o common/job-control.o common/netstuff.o
common/new-op.o common/pathstuff.o common/posix-strerror.o
common/print-utils.o common/ptid.o common/rsp-low.o
common/run-time-clock.o common/scoped_mmap.o
common/signals-state-save-restore.o common/signals.o common/tdesc.o
common/vec.o common/xml-utils.o compile/compile-c-support.o
compile/compile-c-symbols.o compile/compile-c-types.o
compile/compile-cplus-symbols.o compile/compile-cplus-types.o
compile/compile-loc2c.o compile/compile-object-load.o
compile/compile-object-run.o compile/compile.o complaints.o
completer.o continuations.o copying.o corefile.o corelow.o cp-abi.o
cp-name-parser.o cp-namespace.o cp-support.o cp-valprint.o ctf.o
d-exp.o d-lang.o d-namespace.o d-valprint.o dbxread.o dcache.o debug.o
demangle.o dictionary.o disasm-selftests.o disasm.o dtrace-probe.o
dummy-frame.o dwarf-index-cache.o dwarf-index-common.o
dwarf-index-write.o dwarf2-frame-tailcall.o dwarf2-frame.o
dwarf2expr.o dwarf2loc.o dwarf2read.o elfread.o eval.o event-loop.o
event-top.o exceptions.o exec.o expprint.o extension.o f-exp.o
f-lang.o f-typeprint.o f-valprint.o filename-seen-cache.o filesystem.o
findcmd.o findvar.o fork-child.o frame-base.o frame-unwind.o frame.o
gcore.o gdb-dlfcn.o gdb_bfd.o gdb_obstack.o gdb_regex.o gdb_usleep.o
gdbarch-selftests.o gdbarch.o gdbtypes.o glibc-tdep.o gnu-v2-abi.o
gnu-v3-abi.o go-exp.o go-lang.o go-typeprint.o go-valprint.o
guile/guile.o inf-child.o inf-loop.o inf-ptrace.o infcall.o infcmd.o
inferior.o inflow.o infrun.o inline-frame.o interps.o jit.o language.o
linespec.o linux-fork.o linux-nat.o linux-record.o linux-tdep.o
linux-thread-db.o location.o m2-exp.o m2-lang.o m2-typeprint.o
m2-valprint.o macrocmd.o macroexp.o macroscope.o macrotab.o main.o
maint.o mdebugread.o mem-break.o memattr.o memory-map.o memrange.o
mi/mi-cmd-break.o mi/mi-cmd-catch.o mi/mi-cmd-disas.o mi/mi-cmd-env.o
mi/mi-cmd-file.o mi/mi-cmd-info.o mi/mi-cmd-stack.o mi/mi-cmd-target.o
mi/mi-cmd-var.o mi/mi-cmds.o mi/mi-common.o mi/mi-console.o
mi/mi-getopt.o mi/mi-interp.o mi/mi-main.o mi/mi-out.o mi/mi-parse.o
mi/mi-symbol-cmds.o minidebug.o minsyms.o mipsread.o namespace.o
nat/fork-inferior.o nat/linux-namespaces.o nat/linux-osdata.o
nat/linux-personality.o nat/linux-procfs.o nat/linux-ptrace.o
nat/linux-waitpid.o objc-lang.o objfiles.o observable.o opencl-lang.o
osabi.o osdata.o p-exp.o p-lang.o p-typeprint.o p-valprint.o parse.o
posix-hdep.o printcmd.o probe.o proc-service.o
process-stratum-target.o producer.o progspace-and-thread.o progspace.o
prologue-value.o psymtab.o python/python.o record-btrace.o
record-full.o record.o regcache-dump.o regcache.o reggroups.o
registry.o remote-fileio.o remote-notif.o remote.o reverse.o
rust-exp.o rust-lang.o sentinel-frame.o ser-base.o ser-event.o
ser-pipe.o ser-tcp.o ser-uds.o ser-unix.o serial.o skip.o solib-svr4.o
solib-target.o solib.o source-cache.o source.o stabsread.o stack.o
stap-probe.o std-regs.o stub-termcap.o symfile-debug.o symfile-mem.o
symfile.o
symmisc.o symtab.o target-dcache.o target-descriptions.o
target-float.o target-memory.o target.o target/waitstatus.o
test-target.o thread-iter.o thread.o tid-parse.o top.o
tracefile-tfile.o tracefile.o tracepoint.o trad-frame.o tramp-frame.o
typeprint.o ui-file.o ui-out.o ui-style.o user-regs.o utils.o
valarith.o valops.o valprint.o value.o varobj.o version.o
xml-builtin.o xml-support.o xml-syscall.o xml-tdesc.o init.o
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a
-L./../zlib -lz ./../intl/libintl.a ../libiberty/libiberty.a
../libdecnumber/libdecnumber.a   -lm     ../libiberty/libiberty.a
build-gnulib/import/libgnu.a    -ldl

I did copy this one on an arm32 machine and I does run nicely, btw,
this arm machine runs on glibc so if it wasn't statically linked it
could never run:
/lib/libc.so.6
GNU C Library (GLIBC) stable release version 2.19, by Roland McGrath et al.
Copyright (C) 2014 Free Software Foundation, Inc.
[SNIP]

Now on this armv7 machine I run the compiled gdb:
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-musleabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".

Tried loading in some core file (generated by sending a kill 11
signal) and it works fine.
Thanks,

Reinoud.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.