Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix relro, now and PIE for host and libraries #685

Merged
merged 2 commits into from
Dec 10, 2019

Conversation

janvorli
Copy link
Member

@janvorli janvorli commented Dec 9, 2019

The former core-setup and corefx native code build was missing the
-z,relro and -z,now options and also the position independent related
-pie linker option. This change fixes that by adding the missing options
and using the native cmake position independent code support instead
of passing the respective compiler and linker options explicitly.

Close #632

The former core-setup and corefx native code build was missing the
-z,relro and -z,now options and also the position independent related
settings.
@janvorli janvorli added this to the 5.0 milestone Dec 9, 2019
@janvorli janvorli self-assigned this Dec 9, 2019
@janvorli
Copy link
Member Author

janvorli commented Dec 9, 2019

cc: @jeffschwMSFT, @lpereira

@janvorli janvorli merged commit 51470b8 into dotnet:master Dec 10, 2019
@janvorli janvorli deleted the fix-relro-and-now branch December 10, 2019 22:48
@safern
Copy link
Member

safern commented Dec 11, 2019

It seems like this PR broke the Debug build of libraries WebAssembly.

CMake Warning at CMakeLists.txt:11 (message):
PIE is not supported at link time: PIE (C): shared:INFO: (Emscripten:
Running sanity checks)

wasm-ld: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Casting.h:264: typename cast_retty<X, Y >::ret_type llvm::cast(Y ) [X = lld::wasm::FunctionSymbol, Y = const lld::wasm::Symbol]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
Stack dump:
0. Program arguments: /__w/32/b/emsdk/upstream/bin/wasm-ld -o System.Native.bc --allow-undefined --lto-O0 CMakeFiles/System.Native-Static.dir/pal_console.c.o CMakeFiles/System.Native-Static.dir/pal_errno.c.o -L/__w/32/b/emsdk/upstream/emscripten/system/local/lib CMakeFiles/System.Native-Static.dir/pal_interfaceaddresses.c.o -L/__w/32/b/emsdk/upstream/emscripten/system/lib CMakeFiles/System.Native-Static.dir/pal_io.c.o -L/__w/32/b/emsdk/.emscripten_cache/wasm-obj CMakeFiles/System.Native-Static.dir/pal_maphardwaretype.c.o CMakeFiles/System.Native-Static.dir/pal_memory.c.o CMakeFiles/System.Native-Static.dir/pal_mount.c.o CMakeFiles/System.Native-Static.dir/pal_networking.c.o CMakeFiles/System.Native-Static.dir/pal_networkstatistics.c.o CMakeFiles/System.Native-Static.dir/pal_process.c.o CMakeFiles/System.Native-Static.dir/pal_random.c.o CMakeFiles/System.Native-Static.dir/pal_runtimeinformation.c.o CMakeFiles/System.Native-Static.dir/pal_runtimeextensions.c.o CMakeFiles/System.Native-Static.dir/pal_signal.c.o CMakeFiles/System.Native-Static.dir/pal_string.c.o CMakeFiles/System.Native-Static.dir/pal_tcpstate.c.o CMakeFiles/System.Native-Static.dir/pal_time.c.o CMakeFiles/System.Native-Static.dir/pal_uid.c.o CMakeFiles/System.Native-Static.dir/pal_datetime.c.o CMakeFiles/System.Native-Static.dir/pal_sysctl.c.o CMakeFiles/System.Native-Static.dir/__w/32/s/artifacts/obj/_version.c.o --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024 --relocatable
#0 0x00007ff2192330b4 PrintStackTraceSignalHandler(void
) (/__w/32/b/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x7000b4)
#1 0x00007ff219230e3e llvm::sys::RunSignalHandlers() (/__w/32/b/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x6fde3e)
#2 0x00007ff219233368 SignalHandler(int) (/__w/32/b/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x700368)
#3 0x00007ff21c1b9390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007ff217efd428 raise /build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007ff217eff02a abort /build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007ff217ef5bd7 __assert_fail_base /build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0
#7 0x00007ff217ef5c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x00000000006e19f0 lld::wasm::GlobalSection::writeBody() (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x6e19f0)
#9 0x00000000006d22aa lld::wasm::SyntheticSection::finalizeContents() (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x6d22aa)
#10 0x00000000006cc638 (anonymous namespace)::Writer::run() (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x6cc638)
#11 0x00000000006c51a1 lld::wasm::writeResult() (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x6c51a1)
#12 0x00000000006a79bd (anonymous namespace)::LinkerDriver::link(llvm::ArrayRef<char const
>) (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x6a79bd)
#13 0x00000000006a24d8 lld::wasm::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&) (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x6a24d8)
#14 0x000000000041f45b main (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x41f45b)
#15 0x00007ff217ee8830 __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
#16 0x000000000041efe9 _start (/__w/32/b/emsdk/upstream/bin/wasm-ld+0x41efe9)
shared : error : '/__w/32/b/emsdk/upstream/bin/wasm-ld -o System.Native.bc --allow-undefined --lto-O0 CMakeFiles/System.Native-Static.dir/pal_console.c.o CMakeFiles/System.Native-Static.dir/pal_errno.c.o -L/__w/32/b/emsdk/upstream/emscripten/system/local/lib CMakeFiles/System.Native-Static.dir/pal_interfaceaddresses.c.o -L/__w/32/b/emsdk/upstream/emscripten/system/lib CMakeFiles/System.Native-Static.dir/pal_io.c.o -L/__w/32/b/emsdk/.emscripten_cache/wasm-obj CMakeFiles/System.Native-Static.dir/pal_maphardwaretype.c.o CMakeFiles/System.Native-Static.dir/pal_memory.c.o CMakeFiles/System.Native-Static.dir/pal_mount.c.o CMakeFiles/System.Native-Static.dir/pal_networking.c.o CMakeFiles/System.Native-Static.dir/pal_networkstatistics.c.o CMakeFiles/System.Native-Static.dir/pal_process.c.o CMakeFiles/System.Native-Static.dir/pal_random.c.o CMakeFiles/System.Native-Static.dir/pal_runtimeinformation.c.o CMakeFiles/System.Native-Static.dir/pal_runtimeextensions.c.o CMakeFiles/System.Native-Static.dir/pal_signal.c.o CMakeFiles/System.Native-Static.dir/pal_string.c.o CMakeFiles/System.Native-Static.dir/pal_tcpstate.c.o CMakeFiles/System.Native-Static.dir/pal_time.c.o CMakeFiles/System.Native-Static.dir/pal_uid.c.o CMakeFiles/System.Native-Static.dir/pal_datetime.c.o CMakeFiles/System.Native-Static.dir/pal_sysctl.c.o CMakeFiles/System.Native-Static.dir/__w/32/s/artifacts/obj/_version.c.o --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024 --relocatable' failed (-6) [/__w/32/s/src/libraries/Native/build-native.proj]
##[error]shared(0,0): error : (NETCORE_ENGINEERING_TELEMETRY=Build) '/__w/32/b/emsdk/upstream/bin/wasm-ld -o System.Native.bc --allow-undefined --lto-O0 CMakeFiles/System.Native-Static.dir/pal_console.c.o CMakeFiles/System.Native-Static.dir/pal_errno.c.o -L/__w/32/b/emsdk/upstream/emscripten/system/local/lib CMakeFiles/System.Native-Static.dir/pal_interfaceaddresses.c.o -L/__w/32/b/emsdk/upstream/emscripten/system/lib CMakeFiles/System.Native-Static.dir/pal_io.c.o -L/__w/32/b/emsdk/.emscripten_cache/wasm-obj CMakeFiles/System.Native-Static.dir/pal_maphardwaretype.c.o CMakeFiles/System.Native-Static.dir/pal_memory.c.o CMakeFiles/System.Native-Static.dir/pal_mount.c.o CMakeFiles/System.Native-Static.dir/pal_networking.c.o CMakeFiles/System.Native-Static.dir/pal_networkstatistics.c.o CMakeFiles/System.Native-Static.dir/pal_process.c.o CMakeFiles/System.Native-Static.dir/pal_random.c.o CMakeFiles/System.Native-Static.dir/pal_runtimeinformation.c.o CMakeFiles/System.Native-Static.dir/pal_runtimeextensions.c.o CMakeFiles/System.Native-Static.dir/pal_signal.c.o CMakeFiles/System.Native-Static.dir/pal_string.c.o CMakeFiles/System.Native-Static.dir/pal_tcpstate.c.o CMakeFiles/System.Native-Static.dir/pal_time.c.o CMakeFiles/System.Native-Static.dir/pal_uid.c.o CMakeFiles/System.Native-Static.dir/pal_datetime.c.o CMakeFiles/System.Native-Static.dir/pal_sysctl.c.o CMakeFiles/System.Native-Static.dir/__w/32/s/artifacts/obj/_version.c.o --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024 --relocatable' failed (-6)

Example: https://dev.azure.com/dnceng/public/_build/results?buildId=453500

@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-z,relro and -z,now and PIE options missing on libraries and installer binaries
5 participants