View Issue Details

IDProjectCategoryView StatusLast Update
0004780unrealinstallingpublic2016-11-18 16:28
Reporterlundman Assigned Tosyzop  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformIllumOSOSOmniOSOS Versionr151018
Product Version4.0.8.1 
Summary0004780: build quirks on OmniOS
DescriptionAfter Config, configure line ends up as:
./configure --with-showlistmodes --enable-ssl --with-bindir=/usr/local/unrealircd/bin --with-datadir=/usr/local/unrealircd/data --with-pidfile=/usr/local/unrealircd/data/unrealircd.pid --with-confdir=/usr/local/unrealircd/conf --with-modulesdir=/usr/local/unrealircd/modules --with-logdir=/usr/local/unrealircd/logs --with-cachedir=/usr/local/unrealircd/cache --with-docdir=/usr/local/unrealircd/doc --with-tmpdir=/usr/local/unrealircd/tmp --with-privatelibdir=/usr/local/unrealircd/lib --with-scriptdir=/usr/local/unrealircd --with-nick-history=2000 --with-sendq=3000000 --with-permissions=0600 --with-fd-setsize=1024 --enable-dynamic-linking CFLAGS="-m64" CXXFLAGS=-m64" LDFLAGS=-m64

(I add m64 to avoid 32bit compiles)

First dies with:

gcc -I/usr/local/src/unrealircd-4.0.8.2/include -D_REENTRANT -pthreads -I/usr/local/src/unrealircd-4.0.8.2/extras/regexp/include -I/usr/local/src/unrealircd-4.0.8.2/extras/pcre2/include -I/usr/local/src/unrealircd-4.0.8.2/extras/c-ares/include -pipe -m64 -fpic -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE -fPIC -DPIC -shared -DDYNAMIC_LINKING \
        -o cloak.so cloak.c
Text relocation remains referenced
    against symbol offset in file
cloak 0x77 /var/tmp//cc4da43Y.o
cloak 0x7e /var/tmp//cc4da43Y.o
cloak_csum 0xcb /var/tmp//cc4da43Y.o
[snip]

This is due to -fPIE. Didn't see an easy way to remove it, so a quick edit of configure to not add -fPIE, and it compiles until;

cd chanmodes; make all
"==== DO NOT RUN MAKE FROM THIS DIRECTORY ====" -I/usr/local/src/unrealircd-4.0.8.2/include -D_REENTRANT -pthreads -I/usr/local/src/unrealircd-4.0.8.2/extras/regexp/include -I/usr/local/src/unrealircd-4.0.8.2/extras/pcre2/include -I/usr/local/src/unrealircd-4.0.8.2/extras/c-ares/include -pipe -m64 -fpic -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIC -DPIC -shared -DDYNAMIC_LINKING \
        -o nocolor.so nocolor.c
sh: line 1: ==== DO NOT RUN MAKE FROM THIS DIRECTORY ====: not found
*** Error code 127

From top level "make" of course. I simply took out the CC= line from the Makefile in chanmodes, usermodes, snomasks, extbans, then compile continues.

This gets us to;

* UnrealIRCd compiled successfully


TagsNo tags attached.
3rd party modules

Activities

syzop

2016-11-17 09:00

administrator   ~0019529

That last issue ("DO NOT RUN..") I can't explain right now, that's odd.

Anyway, about the 1st issue: Does it only have this problem with 'cloak'? Or is 'cloak' just the first module that gets built that exposes this problem?
Any idea why compiling as position independent code would fail? You're the first one to report an issue with it, is there anything special about OmniOS? Oh, it's (Open)Solaris? Sorry I'm not familiar with it, is it a still supported OS? The information is a bit scarce out there. Do you by chance happen to know how to get PIC/PIE working on it? Worth asking ;)
There's a configure option --disable-hardening to disable all hardening options, but if we can keep it on in some (other) way that would be much better!

lundman

2016-11-17 09:10

reporter   ~0019530

'cloak' is not the only issue, I actually fixed it on the gcc line the first time by just removing "-fPIE" (but leaving -fPIC and -DPIC). Then when it died the same way with "m_chghost.so" I decided it was better to remove from configure.

PIC definitely works, but it didn't like it with PIE as well. OmniOS is the "server distro" of the IllumOS kernel, and very active. OpenIndiana is the "desktop distro" of IllumOS kernel. and IllumOS kernel is what became of the OpenSolaris when Oracle closed development.

I figured I'd leave this note in case someone else wanted to compile it, don't know if you have to fix anything :)

lundman

2016-11-17 09:12

reporter   ~0019531

Ah I can explain the first one. Default make on IllumOS is "dmake", whereas if I run "gmake" it appears to be quite happy compiling the modules. So we can put that down as a "path" problem.

syzop

2016-11-17 20:08

administrator   ~0019533

I just had a user on Centos with a similar issue. It tells the user to recompile with -fPIC even though you can clearly see it being used...

gcc -I/home/ircd/unrealircd-4.0.8.3/include -pthread -I/home/ircd/unrealircd-4.0.8.3/extras/regexp/include -I/home/ircd/unrealircd-4.0.8.3/extras/pcre2/include -I/home/ircd/unrealircd-4.0.8.3/extras/c-ares/include -pipe -g -O2 -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -Wl,-export-dynamic -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE -c crashreport.c
gcc -I/home/ircd/unrealircd-4.0.8.3/include -pthread -I/home/ircd/unrealircd-4.0.8.3/extras/regexp/include -I/home/ircd/unrealircd-4.0.8.3/extras/pcre2/include -I/home/ircd/unrealircd-4.0.8.3/extras/c-ares/include -pipe -g -O2 -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -Wl,-export-dynamic -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE -lssl -lcrypto -o ircd timesynch.o res.o s_bsd.o auth.o aln.o channel.o cloak.o crule.o dbuf.o events.o fdlist.o hash.o ircd.o ircsprintf.o list.o match.o modules.o packet.o parse.o s_auth.o mempool.o operclass.o s_conf.o s_debug.o s_dispatch.o s_err.o s_extra.o s_kline.o s_misc.o s_numeric.o s_serv.o s_svs.o socket.o ssl.o s_user.o charsys.o scache.o send.o support.o umodes.o version.o whowas.o random.o extcmodes.o moddata.o uid.o extbans.o api-isupport.o api-command.o api-clicap.o md5.o crypt_blowfish.o updconf.o crashreport.o -Wl,-rpath=/home/ircd/unrealircd/lib -pie -Wl,-z,relro -Wl,-z,now -lcrypt -lnsl -ldl -Wl,-rpath=/home/ircd/unrealircd/lib -L/home/ircd/unrealircd/lib -ltre -L/home/ircd/unrealircd/lib -lpcre2-8 -L/home/ircd/unrealircd/lib /home/ircd/unrealircd/lib/libcares.so -lssl -lcrypto
cd modules; make 'CFLAGS=-I/home/ircd/unrealircd-4.0.8.3/include -pthread -I/home/ircd/unrealircd-4.0.8.3/extras/regexp/include -I/home/ircd/unrealircd-4.0.8.3/extras/pcre2/include -I/home/ircd/unrealircd-4.0.8.3/extras/c-ares/include -pipe -g -O2 -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -Wl,-export-dynamic -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE ' 'CC=gcc' 'IRCDLIBS=-lcrypt -lnsl -ldl -Wl,-rpath=/home/ircd/unrealircd/lib -L/home/ircd/unrealircd/lib -ltre -L/home/ircd/unrealircd/lib -lpcre2-8 -L/home/ircd/unrealircd/lib /home/ircd/unrealircd/lib/libcares.so ' 'LDFLAGS=-Wl,-rpath=/home/ircd/unrealircd/lib -pie -Wl,-z,relro -Wl,-z,now' 'IRCDMODE=711' 'BINDIR=/home/ircd/unrealircd/bin' 'INSTALL=/usr/bin/install' 'INCLUDEDIR=/home/ircd/unrealircd-4.0.8.3/include' 'MANDIR=' 'RM=/bin/rm' 'CP=/bin/cp' 'TOUCH=/bin/touch' 'RES=' 'SHELL=/bin/sh' 'STRTOUL=' 'CRYPTOLIB=-lssl -lcrypto' 'CRYPTOINCLUDES=' 'URL=' all
make[2]: Entering directory `/home/ircd/unrealircd-4.0.8.3/src/modules'
gcc -I/home/ircd/unrealircd-4.0.8.3/include -pthread -I/home/ircd/unrealircd-4.0.8.3/extras/regexp/include -I/home/ircd/unrealircd-4.0.8.3/extras/pcre2/include -I/home/ircd/unrealircd-4.0.8.3/extras/c-ares/include -pipe -g -O2 -funsigned-char -fno-strict-aliasing -Wno-pointer-sign -Wl,-export-dynamic -fno-strict-overflow -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE -fPIC -DPIC -shared -DDYNAMIC_LINKING \
                -o cloak.so cloak.c
/usr/bin/ld: /tmp/ccOF2ynm.o: relocation R_X86_64_PC32 against symbol `cloak_config_run' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [cloak.so] Error 1
make[2]: Leaving directory `/home/ircd/unrealircd-4.0.8.3/src/modules'
make[1]: *** [mods] Error 2
make[1]: Leaving directory `/home/ircd/unrealircd-4.0.8.3/src'
make: *** [build] Error 2

Also when checking via checksec.sh it shows full relro and all on the src/ircd binary. Hmmmmmmmm...

syzop

2016-11-17 20:27

administrator   ~0019534

Ok thank you for the additional information :). I'll see if I can get some more useful google results / debugging later. Unfortunately haven't found anything yet, so no idea at this point.
The centos user also successfully compiled only after --disable-hardening.

syzop

2016-11-18 16:27

administrator   ~0019535

Fixed in 4.0.8.4 :)

It was also an issue on a few (older) Linux distro's, so pretty major.

Thanks again for the report.

syzop

2016-11-18 16:28

administrator   ~0019536

Fix build problem on CentOS and others.

Only build main binary with -fPIE, not the modules. It's called Position
Independent EXECUTABLE after all. And apparently not all compilers or
linkers ignore the option if building shared objects (mine did..).

https://github.com/unrealircd/unrealircd/commit/4fd616f94098124b290832f39e7df82d2a59b752

Issue History

Date Modified Username Field Change
2016-11-17 08:01 lundman New Issue
2016-11-17 09:00 syzop Note Added: 0019529
2016-11-17 09:10 lundman Note Added: 0019530
2016-11-17 09:12 lundman Note Added: 0019531
2016-11-17 20:08 syzop Note Added: 0019533
2016-11-17 20:27 syzop Note Added: 0019534
2016-11-18 16:27 syzop Assigned To => syzop
2016-11-18 16:27 syzop Status new => resolved
2016-11-18 16:27 syzop Resolution open => fixed
2016-11-18 16:27 syzop Note Added: 0019535
2016-11-18 16:28 syzop Note Added: 0019536