dosemu2 / fdpp

FreeDOS plus-plus, 64bit DOS
GNU General Public License v3.0
198 stars 18 forks source link

linker error: section .ptext virtual address range overlaps with .note.gnu.build-id #209

Closed Baron-von-Riedesel closed 1 year ago

Baron-von-Riedesel commented 1 year ago

Hello,

I got this when trying to build fdpp:

/usr/bin/ld.lld -melf_i386 -static --build-id=sha1 -Map=fdppkrnl.map -o fdppkrnl.elf \
    -T/home/sam/fdpp/fdpp/kernel.ld kernel.o entry.o io.o console.o serial.o printer.o execrh.o nlssupt.o procsupt.o dosidle.o int2f.o nls_hc.o intr.o irqstack.o cpu.o plt.o cdata.o floppy.o rdpcclk.o wrpcclk.o wratclk.o --defsym=DOS_PSP=0x60
ld.lld: error: section .ptext virtual address range overlaps with .note.gnu.build-id
>>> .ptext range is [0x0, 0xFF]
>>> .note.gnu.build-id range is [0x14, 0x37]

No idea what this is supposed to mean...

Using debian 11

stsp commented 1 year ago

This means a buggy version of lld. You need to remove it and then fdpp will use ld instead. You can as well report that upstream, asking them to update.

Baron-von-Riedesel commented 1 year ago

Thanks!

edrx commented 1 year ago

Hi @stsp, I'm on Debian stable - Debian 11.6 - and I'm trying to find a way to make fdpp use a recent lld that disturbs the system as least as possible... in my Debian box I can install lld-13 by just doing "apt-get install lld-13", but I'm not being able an easy way to make lld-13 the default. If I do this - note the step in which a line is changed by hand - then fdpp builds fine:

rm -Rfv /tmp/fdpp/
cd      /tmp/
git clone https://github.com/dosemu2/fdpp.git
cd      /tmp/fdpp/

./configure
#
# (find-fline "/tmp/fdpp/fdpp/clang.mak")
# Now change the line 5 in /tmp/fdpp/fdpp/clang.mak from:
#   LLD = $(shell which ld.lld)
# to:
#   LLD = $(shell which ld.lld-13)
#
make

I couldn't find a way to change the value of LDD by calling configure or make with different command-line parameters, though... am I missing something obvious? Would it be worthwhile to change fdpp a bit to make it easy to select which ld.lld to use?

Thanks in advance!

stsp commented 1 year ago

Try make CROSS_LD=ld.lld-13

stsp commented 1 year ago

I also added a change to allow overriding via env vars, so now this should also work: CROSS_LD=ld.lld-13 make

edrx commented 1 year ago

Thanks!!! =) My build script now is essentially this,

mkdir   ~/usrc/

rm -Rfv ~/usrc/fdpp/
cd      ~/usrc/
git clone https://github.com/dosemu2/fdpp.git
cd      ~/usrc/fdpp/

export CROSS_LD=ld.lld-13

./configure
make
make deb

The first "make" runs perfectly, but the "make deb" still uses /usr/bin/ld.lld, and fails. Would you like to apply similar fixes to other makefiles and their includes? Thanks in advance! =) =) =)

stsp commented 1 year ago

There are no includes, so I think debhelperes reset the environment perhaps. Try adding your export CROSS_LD=ld.lld-13 directly into debian/rules, right after #!/usr/bin/make -f line.

edrx commented 1 year ago

Works!!! Many thanks! =) I had a few problems compiling the debs for dosemu2 and comcom2... but tomorrow I will try some more and I'll report the problems that I can't fix in the dosemu2/comcom2 pages!

stsp commented 1 year ago

Just wondering, why would you do

make
make deb

These are either-or. You don't need make before make deb.

stsp commented 1 year ago

I had a few problems compiling the debs for dosemu2 and comcom2...

comcom32 may be a PITA to build. Here: https://github.com/dosemu2/dosemu2/wiki/Building-packages-for-Debian we describe the trick to simplify the build (there is no build at all under that scenario). I am slowly moving to the 64bit port of comcom32, but this appears hellish amount of work (needs to write tool-chain first).

edrx commented 1 year ago

Hi! The build instructions in

https://github.com/dosemu2/dosemu2/wiki/Building-packages-for-Debian

worked here (Debian 11), modulo one change and one bug. To make fdpp use ld.ldd-13 I had to do this,

rm -Rfv ~/usrc/fdpp/
mkdir   ~/usrc/fdpp/
cd      ~/usrc/fdpp/
git clone https://github.com/dosemu2/fdpp.git .
mk-build-deps --install --root-cmd sudo --remove

cd      ~/usrc/fdpp/fdpp/
patch clang.mak <<'%%%'
5c5
< LLD ?= $(shell which ld.lld)
---
> LLD ?= $(shell which ld.lld-13)
%%%

cd ~/usrc/fdpp/
make deb

and then the .debs for fdpp, comcom2, and dosemu2, were all built correctly, except for one thing: when I run "dosemu" I get this error:

/tmp(edrx:sc)# dosemu
ERROR: libfdpp.so: cannot open shared object file: No such file or directory
ERROR: can't load fdpp
ERROR: userspace pings are disabled.
    To enable them, do as root:
    echo 0 65535 > /proc/sys/net/ipv4/ping_group_range
ERROR: Bootable drive not found, exiting
/tmp(edrx:sc)# ls -lAF /usr/lib/fdpp/
total 976
-rw-r--r-- 1 root root 998584 Jan 17  2022 libfdpp.so
/tmp(edrx:sc)#

and I haven't found a fix for it yet... =(

stsp commented 1 year ago

readelf -d /usr/lib/dosemu/libplugin_fdpp.so |grep RUNPATH This will show where does it look for libfdpp.so.

edrx commented 1 year ago

"readelf -d /usr/lib/dosemu/libplugin_fdpp.so | grep RUNPATH" says this,

 0x000000000000001d (RUNPATH)            Library runpath: [/usr/lib/fdpp]

and I also ran this to check if the output of the "ldd"s would have a "not found" at some point...

for i in /usr/lib/dosemu/*.so \
         /usr/lib/fdpp/*.so; do
  echo $i
  ldd $i
done > /tmp/o
grep found /tmp/o

There are no "not found"s there, all files link only to things that exist. If you need to check it, I uploaded my file /tmp/o to: https://0x0.st/ohmO.txt

stsp commented 1 year ago

I suspect you have another libplugin_fdpp.so, maybe in /usr/local/lib. I suspect you didnt pass prefix in your deb rules, and by default /usr/local is used. If not - please use strace to find out where does it look for libs.