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:0000000000000000 push rbp .text:0000000000000001 jmp short loc_32 .text:0000000000000003 ; --------------------------------------------------------------------------- .text:0000000000000003 mov rbp, 32h .text:000000000000000A mov rbp, 32h .text:0000000000000011 mov rbp, qword ptr ds:loc_32 .text:0000000000000019 mov rbp, qword ptr ds:loc_32 .text:0000000000000021 db 2Eh .text:0000000000000021 mov rbp, qword ptr loc_32 .text:000000000000002A lea rbp, ds:32h .text:0000000000000032 .text:0000000000000032 loc_32: ; CODE XREF: test+1↑j .text:0000000000000032 ; DATA XREF: test+11↑r ... .text:0000000000000032 push rbp .text:0000000000000033 mov eax, 0 .text:0000000000000038 retn I need to link this file with vc++: Then use the disassembler to see the pe file with the link succeeded: .text:0000000140011820 sub_140011820 proc near ; CODE XREF: sub_140011307↑j .text:0000000140011820 push rbp .text:0000000140011821 jmp short loc_140011852 .text:0000000140011823 ; --------------------------------------------------------------------------- .text:0000000140011823 mov rbp, 32h .text:000000014001182A mov rbp, 32h .text:0000000140011831 mov rbp, ds:32h .text:0000000140011839 mov rbp, ds:32h .text:0000000140011841 db 2Eh .text:0000000140011841 mov rbp, cs:32h .text:000000014001184A lea rbp, ds:32h .text:0000000140011852 .text:0000000140011852 loc_140011852: ; CODE XREF: sub_140011820+1↑j .text:0000000140011852 push rbp .text:0000000140011853 mov eax, 0 .text:0000000140011858 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.