Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Workaround] Gcc 6.4.0 hardened and palemoon-27.6.2
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
gengreen
Apprentice
Apprentice


Joined: 23 Dec 2017
Posts: 150

PostPosted: Tue Jan 02, 2018 5:09 am    Post subject: [Workaround] Gcc 6.4.0 hardened and palemoon-27.6.2 Reply with quote

Hi,

I found a workaround to build www-client/palemoon available on the overlay

About the config used

Code:
gcc -v


Code:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/6.4.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-6.4.0/work/gcc-6.4.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/6.4.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.4.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.4.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/6.4.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/6.4.0/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 6.4.0 p1.1' --enable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --enable-libmpx --enable-vtable-verify --enable-libvtv --disable-libquadmath --enable-lto --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp
Thread model: posix
gcc version 6.4.0 (Gentoo Hardened 6.4.0 p1.1)


Code:
eix palemoon


Code:
www-client/palemoon
     Available versions:  27[1] {M}~27.5.0^m[2] {M}~27.5.1^m[2] {M}~27.5.1-r1^m[2] {M}~27.6.0^m[2] {M}~27.6.1^m[2] {M}(~)27.6.2^m[2] {alsa dbus debug +devtools ffmpeg +gtk2 -gtk3 jemalloc -necko-wifi +official-branding +optimize pulseaudio shared-js -system-bzip2 -system-libevent -system-libvpx -system-libwebp -system-sqlite -system-zlib threads -valgrind -webrtc CPU_FLAGS_X86="sse sse2" LINGUAS="cs de en_GB es_AR es_ES es_MX fr hu it ko nl pl pt_BR pt_PT ru sv_SE tr zh_CN"}
     Installed versions:  27.6.2^m[2](09:35:19 PM 01/01/2018)(gtk2 optimize system-bzip2 system-libevent system-libvpx system-libwebp system-sqlite system-zlib -alsa -dbus -debug -devtools -ffmpeg -gtk3 -jemalloc -necko-wifi -official-branding -pulseaudio -shared-js -threads -valgrind -webrtc CPU_FLAGS_X86="sse sse2")


Code:
/etc/portage/package.use/www-client


Code:
www-client/palemoon system-zlib system-sqlite system-libwebp system-libvpx system-libevent system-bzip2 -necko-wifi -devtools -official-branding


About the error

Code:
../../build/unix/gold/ld: error: /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/o/toolkit/library/../../media/libstagefright/Unified_cpp_media_libstagefright0.o: requires dynamic R_X86_64_PC32 reloc against '_Z13GetDemuxerLogv' which may overflow at runtime; recompile with -fPIC
../../build/unix/gold/ld: error: read-only segment has dynamic relocations
 /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:728: error: undefined reference to 'GetDemuxerLog()'
/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:735: error: undefined reference to 'GetDemuxerLog()'
/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:804: error: undefined reference to 'GetDemuxerLog()'
/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp:812: error: undefined reference to 'GetDemuxerLog()'


Full build log available here

https://paste.pound-python.org/show/WJ0rtwSGTyUkN0x6O0nz/

The workaround

I would like to say first that is a very dirty hack, but the build will complete without changing any CFLAGS/CXXFLAGS. In my opinion the problem isn't PIE itself but related to
to the code MoofParser.cpp

https://github.com/MoonchildProductions/Pale-Moon/blob/master/media/libstagefright/binding/MoofParser.cpp

Code:
#include "prlog.h"

#ifdef PR_LOGGING
extern PRLogModuleInfo* GetDemuxerLog();

/* Polyfill __func__ on MSVC to pass to the log. */
#ifdef _MSC_VER
#define __func__ __FUNCTION__
#endif

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define LOG(name, arg, ...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (TOSTRING(name) "(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))


LOG() is the function that mess the build, which use the lib nspr (prlog.h is part of nspr)

Code:
dev-libs/nspr


The workaround I made is simple, I removed the Log() function of Moonparser.cpp

https://paste.pound-python.org/show/iVRM9xr9d377A89GZMLg/

To make the build working, emerge palemoon and wait at least, until you see

Code:
> Source configured.
>>> Compiling source in
>>> /var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2
>>> ...


Make sure the Moonparser.cpp is available in :

Code:
/var/tmp/portage/www-client/palemoon-27.6.2/work/palemoon-27.6.2/media/libstagefright/binding/MoofParser.cpp


And replace it by the dirty hack I provided

Full success build available here :

https://paste.pound-python.org/show/4rm2CxbWqFEURoqenDpt/

Hope it's helping.

[Moderator edit: changed some [quote] tags to [code] tags to preserve output layout. -Hu]
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30888
Location: here

PostPosted: Tue Jan 02, 2018 7:49 am    Post subject: Reply with quote

Here a patch to use with /etc/portage/patches
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
gengreen
Apprentice
Apprentice


Joined: 23 Dec 2017
Posts: 150

PostPosted: Tue Jan 02, 2018 8:22 am    Post subject: Reply with quote

fedeliallalinea wrote:
Here a patch to use with /etc/portage/patches


Nice thanks for this patch, far more practical.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum