Wie ist die Bedingung für die Symbolgleichheit für einen Linker unter Windows?C++

Programme in C++. Entwicklerforum
Anonymous
 Wie ist die Bedingung für die Symbolgleichheit für einen Linker unter Windows?

Post by Anonymous »

Ich schreibe einen Linker für Windows. Ich habe ein einfaches "Hello World" -Programm mit Cl.exe zusammengestellt, und jetzt versuche ich es mit meinem benutzerdefinierten Linker zu verknüpfen, aber es funktioniert nicht. Es funktioniert gut mit link.exe .

Code: Select all

// hello.c
#include 

int main(void) {
printf("Hello, Windows!\n");
return 0;
}
Die generierte Objektdatei enthält ein undefiniertes Symbol mit dem Namen? _optionsStorage@? 1? __ local_stdio_printf_options @@ 9@9 .

Code: Select all

# dumpbin output
00F 00000000 SECT4  notype ()    External     | ___local_stdio_printf_options
010 00000000 UNDEF  notype ()    External     | ___acrt_iob_func
011 00000000 UNDEF  notype ()    External     | ___stdio_common_vfprintf
012 00000000 SECT5  notype ()    External     | __vfprintf_l
013 00000000 SECT6  notype ()    External     | _printf
014 00000000 SECT3  notype ()    External     | _main
015 00000008 UNDEF  notype       External     | ?_OptionsStorage@?1??__local_stdio_printf_options@@9@9 (`__local_stdio_printf_options'::`2'::_OptionsStorage)
016 00000000 SECT7  notype       Static       | .data
Section length   11, #relocs    0, #linenums    0, checksum F2A3A4F3
018 00000000 SECT7  notype       Static       | $SG9585
019 00000000 SECT8  notype       Static       | .chks64
Section length   40, #relocs    0, #linenums    0, checksum        0
< /code>
Mein Linker kann dieses Symbol nicht beheben, da es Symbole mit einem einfachen String -Vergleich vergleicht. libcmt.lib 
Enthält ein ähnliches Symbol namens? _optionsStorage@? 1 ?? __ local_stdio_printf_options @@ 9@4_ka In einer seiner Objektdateien:

Code: Select all

# dumpbin output
07A 00000000 SECT27 notype       Static       | .xdata$x
Section length   1C, #relocs    2, #linenums    0, checksum 6A27921E, selection    5 (pick associative Section 0x1C)
07C 00000000 SECT27 notype       Static       | __sehtable$?notify_debugger@@YAXABUtagEXCEPTION_VISUALCPP_DEBUG_INFO@@@Z
07D 00000000 SECT28 notype       Static       | .bss
Section length    8, #relocs    0, #linenums    0, checksum        0, selection    2 (pick any)
07F 00000000 SECT28 notype       External     | ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA (unsigned __int64 `__local_stdio_printf_options'::`2'::_OptionsStorage)
080 00000000 SECT29 notype       Static       | .rdata
Section length   6C, #relocs    0, #linenums    0, checksum DD6D9A7E, selection    2 (pick any)
082 00000000 SECT29 notype       External     | ??_C@_1GM@CNOOJIHC@?$AAR?$AAu?$AAn?$AAt?$AAi?$AAm?$AAe?$AA?5?$AAC?$AAh?$AAe?$AAc?$AAk?$AA?5?$AAE@ (`string')
083 00000000 SECT2A notype       Static       | .rdata
< /code>
Diese Symbole sehen sehr ähnlich aus. Wenn ich undname.exe 
verwende, um sie zu entlarven, sieht es so aus, als ob er erstere ein Suffix des letzteren ist:

Code: Select all

Undecoration of :- "?_OptionsStorage@?1??__local_stdio_printf_options@@9@9"
is :- "`__local_stdio_printf_options'::`2'::_OptionsStorage"

Undecoration of :- "?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA"
is :- "unsigned __int64 `__local_stdio_printf_options'::`2'::_OptionsStorage"
< /code>
Aber das reicht nicht aus, um meine Fragen zu beantworten. Was sind: < /p>
[list]
[*] Wie finde ich heraus, ob? _OptionsStorage@? 1 ?? __ local_stdio_printf_options @@ 9@4_ka 
ist das Symbol, das Link.exe verwendet, um das undefinierte Symbol in Hello.obj erfolgreich aufzulösen? Ausführen link.exe mit/verbose und/oder/map scheint mir diese Informationen nicht zu geben.
[*] Wenn dieses Ist die Definition, die für die Symbolauflösung ausgewählt wird, warum? Die Symbolnamen sind nicht genau die gleichen. Wie mache ich das robust?
[/list]

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post