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

linking error: bad reloc address 0x0 in section `.rdata' #37038

Closed
c0ldhell opened this issue Oct 8, 2016 · 2 comments
Closed

linking error: bad reloc address 0x0 in section `.rdata' #37038

c0ldhell opened this issue Oct 8, 2016 · 2 comments

Comments

@c0ldhell
Copy link

c0ldhell commented Oct 8, 2016

Hi.

rustc 1.14.0-nightly (3210fd5c2 2016-10-05)
binary: rustc
commit-hash: 3210fd5c20ffc6da420eb00e60bdc8704577fd3b
commit-date: 2016-10-05
host: x86_64-unknown-linux-gnu
release: 1.14.0-nightly
$ i686-w64-mingw32-gcc -v
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/4.8/lto-wrapper
Target: i686-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --libexecdir='/usr/lib/gcc-mingw-w64' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --enable-version-specific-runtime-libs --enable-threads=posix --enable-fully-dynamic-string --enable-sjlj-exceptions --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++ --enable-lto --with-plugin-ld --target=i686-w64-mingw32 --with-gxx-include-dir=/usr/include/c++/4.8 --with-as=/usr/bin/i686-w64-mingw32-as --with-ld=/usr/bin/i686-w64-mingw32-ld
Thread model: posix
gcc version 4.8.2 (GCC) 

I install rustup target add i686-pc-windows-gnu toolchain and edit cargo config

$ cat ~/.cargo/config
[target.x86_64-pc-windows-gnu]
linker = "/usr/bin/x86_64-w64-mingw32-gcc"

[target.i686-pc-windows-gnu]
linker = "/usr/bin/i686-w64-mingw32-gcc"

Then build for x86_64

$ cargo build --release --target "x86_64-pc-windows-gnu"
   Compiling foo v0.1.0 (file:///home/user/Projects/rust/foo)
    Finished release [optimized] target(s) in 0.62 secs

That's ok, no questions.

But if I compile to i686

$ LANGUAGE=en_US.UTF-8 cargo build --release --target "i686-pc-windows-gnu"
   Compiling foo v0.1.0 (file:///home/user/Projects/rust/foo)
error: linking with `/usr/bin/i686-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "/usr/bin/i686-w64-mingw32-gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-Wl,--large-address-aware" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/crt2.o" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o" "-L" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib" "/home/user/Projects/rust/foo/target/i686-pc-windows-gnu/release/foo.0.o" "-o" "/home/user/Projects/rust/foo/target/i686-pc-windows-gnu/release/foo.exe" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/user/Projects/rust/foo/target/i686-pc-windows-gnu/release/deps" "-L" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libstd-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_unwind-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libunwind-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/librand-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libcollections-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/librustc_unicode-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/liblibc-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/liballoc-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/liballoc_system-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libcore-6eb85298.rlib" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libcompiler_builtins-6eb85298.rlib" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-l" "advapi32" "-l" "gcc_eh" "-l" "gcc_eh" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/rsend.o"
  = note: /home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_unwind-6eb85298.rlib(panic_unwind-6eb85298.0.o):(.text+0x2e5): undefined reference to `_Unwind_Resume'
/home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_unwind-6eb85298.rlib(panic_unwind-6eb85298.0.o):(.text+0x609): undefined reference to `_Unwind_RaiseException'
/usr/bin/i686-w64-mingw32-ld: /home/user/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_unwind-6eb85298.rlib(panic_unwind-6eb85298.0.o): bad reloc address 0x0 in section `.rdata'
collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `foo`.

To learn more, run the command again with --verbose.

@c0ldhell c0ldhell changed the title Crosscompiling: bad reloc address 0x0 in section `.rdata' bad reloc address 0x0 in section `.rdata' Oct 8, 2016
@c0ldhell c0ldhell changed the title bad reloc address 0x0 in section `.rdata' linking error: bad reloc address 0x0 in section `.rdata' Oct 8, 2016
@retep998
Copy link
Member

retep998 commented Oct 8, 2016

The actual error is this: undefined reference to _Unwind_RaiseException'`.

Furthermore I believe this is a dupe of #32859

@c0ldhell
Copy link
Author

c0ldhell commented Oct 8, 2016

Thanks, this #32859 (comment) solution work for me. Now I download and install rust-nightly-i686-pc-windows-gnu.msi on wine and copied ~/.wine/drive_c/Program\ Files\ \(x86\)/Rust\ nightly\ GNU\ 1.14/lib/rustlib/i686-pc-windows-gnu/lib to ~/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/i686-pc-windows-gnu/lib.


```$ cargo build --release --target "i686-pc-windows-gnu"
   Compiling foo v0.1.0 (file:///home/user/Projects/rust/foo)
    Finished release [optimized] target(s) in 0.67 secs
$ file target/i686-pc-windows-gnu/release/foo.exe 
target/i686-pc-windows-gnu/release/foo.exe: PE32 executable (console) Intel 80386, for MS Windows

@c0ldhell c0ldhell closed this as completed Oct 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants