[Bug c++/89401] New: The generated object file does not automatically relocate the address using the cl link
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89401 Bug ID: 89401 Summary: The generated object file does not automatically relocate the address using the cl link Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rdmsr at protonmail dot com Target Milestone: --- __asm__ ( "push rbp;\n\t" "jmp Label;\n\t" "mov rbp,offset cs:Label;\n\t" "mov rbp,offset Label;\n\t" "mov rbp,Label;\n\t" "mov rbp,Label;\n\t" "mov rbp,cs:Label;\n\t" "lea rbp,Label;\n\t" "Label:\n\t" "push rbp;\n\t" ); I want to use GCC inline assembly to get the Label address. Use the following command to get the object file: gcc64 -c -s -masm=intel 1.cpp Now I get the file 1.o I used a disassembler to view assembly instructions: .text: pushrbp .text:0001 jmp short loc_32 .text:0003 ; --- .text:0003 mov rbp, 32h .text:000A mov rbp, 32h .text:0011 mov rbp, qword ptr ds:loc_32 .text:0019 mov rbp, qword ptr ds:loc_32 .text:0021 db 2Eh .text:0021 mov rbp, qword ptr loc_32 .text:002A lea rbp, ds:32h .text:0032 .text:0032 loc_32: ; CODE XREF: test+1↑j .text:0032 ; DATA XREF: test+11↑r ... .text:0032 pushrbp .text:0033 mov eax, 0 .text:0038 retn I need to link this file with vc++: Then use the disassembler to see the pe file with the link succeeded: .text:000140011820 sub_140011820 proc near ; CODE XREF: sub_140011307↑j .text:000140011820 pushrbp .text:000140011821 jmp short loc_140011852 .text:000140011823 ; --- .text:000140011823 mov rbp, 32h .text:00014001182A mov rbp, 32h .text:000140011831 mov rbp, ds:32h .text:000140011839 mov rbp, ds:32h .text:000140011841 db 2Eh .text:000140011841 mov rbp, cs:32h .text:00014001184A lea rbp, ds:32h .text:000140011852 .text:000140011852 loc_140011852: ; CODE XREF: sub_140011820+1↑j .text:000140011852 pushrbp .text:000140011853 mov eax, 0 .text:000140011858 retn As you see now, he doesn't seem to relocate the address. When I used nasm to generate object files it did it。 I don't know if it's a bug or a feature missing, just report it now.
[Bug c++/89401] The generated object file does not automatically relocate the address using the cl link
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89401 --- Comment #1 from syscall --- gcc -v: Using built-in specs. COLLECT_GCC=gcc64 COLLECT_LTO_WRAPPER=D:/Program\ Files\ (x86)/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)