Различия в объектном файле g ++ - PullRequest
0 голосов
/ 04 марта 2020

У меня есть объектный файл, который меняется от сборки к сборке. Я хотел бы иметь возможность создать согласованный / воспроизводимый объектный файл. Почему g ++ не создает согласованный объектный файл? Есть ли способ изменить это поведение?

(усеченная) команда g ++:

g++  ... -fexceptions -frtti -fPIC -fno-defer-pop -D_REENTRANT -DBOOST_BIND_NO_PLACEHOLDERS -Wall -Wno-unknown-pragmas -Werror -DNDEBUG -O3 -g -c PresentationRandNumGenerator.cpp -o PresentationRandNumGenerator.o

g ++ версия (я не могу изменить это):

bash -2.05b # g ++ -v

Reading specs from /usr/lib/gcc/i586-montavista-linux/3.4.3/specs
Configured with: ../configure --host=i586-montavista-linux --build=i686-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/share --mandir=/usr/share/man --infodir=/usr/share/info --target=i586-montavista-linux --program-prefix= --enable-__cxa_atexit --enable-shared --enable-languages=c,c++ --enable-threads=posix --disable-multilib --with-numa-policy=no --with-cpu=i586 --libexecdir=/usr/lib
Thread model: posix
gcc version 3.4.3 (MontaVista 3.4.3-25.0.30.0501131 2005-07-22)

Некоторый диффузный вывод, показывающий разницу выходных данных. Некоторые разделы кажутся в другом порядке между двумя объектными файлами.

--- a/PresentationRandNumGenerator.o
+++ b/PresentationRandNumGenerator.o
├── readelf --wide --sections {}
│ @@ -156,16 +156,16 @@
│    [151] .group            GROUP           00000000 000508 000008 04     487 432  4
│    [152] .group            GROUP           00000000 000510 000008 04     487 481  4
│    [153] .group            GROUP           00000000 000518 000008 04     487 614  4
│    [154] .group            GROUP           00000000 000520 000008 04     487 413  4
│    [155] .group            GROUP           00000000 000528 000008 04     487 412  4
│    [156] .group            GROUP           00000000 000530 000008 04     487 617  4
│    [157] .group            GROUP           00000000 000538 000008 04     487 486  4
│ -  [158] .group            GROUP           00000000 000540 000008 04     487 607  4
│ -  [159] .group            GROUP           00000000 000548 000008 04     487 621  4
│ +  [158] .group            GROUP           00000000 000540 000008 04     487 621  4
│ +  [159] .group            GROUP           00000000 000548 000008 04     487 607  4
│    [160] .text             PROGBITS        00000000 000550 0013b0 00  AX  0   0 16
│    [161] .rel.text         REL             00000000 073370 000598 08     487 160  4
│    [162] .data             PROGBITS        00000000 001900 000000 00  WA  0   0  4
│    [163] .bss              NOBITS          00000000 001900 000018 00  WA  0   0  4
│    [164] .debug_abbrev     PROGBITS        00000000 001900 000a57 00      0   0  1
│    [165] .debug_info       PROGBITS        00000000 002357 0241a5 00      0   0  1
│    [166] .rel.debug_info   REL             00000000 073908 0118e0 08     487 165  4
│ @@ -478,18 +478,18 @@
│    [473] .debug_pubnames   PROGBITS        00000000 0322d4 0073e3 00      0   0  1
│    [474] .rel.debug_pubnames REL             00000000 087830 000008 08     487 473  4
│    [475] .debug_aranges    PROGBITS        00000000 0396b7 000390 00      0   0  1
│    [476] .rel.debug_aranges REL             00000000 087838 000380 08     487 475  4
│    [477] .debug_ranges     PROGBITS        00000000 039a47 000b88 00      0   0  1
│    [478] .rel.debug_ranges REL             00000000 087bb8 001120 08     487 477  4
│    [479] .debug_str        PROGBITS        00000000 03a5cf 02aec4 01  MS  0   0  1
│ -  [480] .data.DW.ref._ZTIN5boost16bad_lexical_castE PROGBITS        00000000 065494 000004 00 WAG  0   0  4
│ -  [481] .rel.data.DW.ref._ZTIN5boost16bad_lexical_castE REL             00000000 088cd8 000008 08     487 480  4
│ -  [482] .data.DW.ref.__gxx_personality_v0 PROGBITS        00000000 065498 000004 00 WAG  0   0  4
│ -  [483] .rel.data.DW.ref.__gxx_personality_v0 REL             00000000 088ce0 000008 08     487 482  4
│ +  [480] .data.DW.ref.__gxx_personality_v0 PROGBITS        00000000 065494 000004 00 WAG  0   0  4
│ +  [481] .rel.data.DW.ref.__gxx_personality_v0 REL             00000000 088cd8 000008 08     487 480  4
│ +  [482] .data.DW.ref._ZTIN5boost16bad_lexical_castE PROGBITS        00000000 065498 000004 00 WAG  0   0  4
│ +  [483] .rel.data.DW.ref._ZTIN5boost16bad_lexical_castE REL             00000000 088ce0 000008 08     487 482  4
│    [484] .note.GNU-stack   PROGBITS        00000000 06549c 000000 00      0   0  1
│    [485] .comment          PROGBITS        00000000 06549c 000040 00      0   0  1
│    [486] .shstrtab         STRTAB          00000000 0654dc 003146 00      0   0  1
│    [487] .symtab           SYMTAB          00000000 06d28c 0026f0 10     488 362  4
│    [488] .strtab           STRTAB          00000000 06f97c 0039f2 00      0   0  1
│  Key to Flags:
│    W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
├── readelf --wide --symbols {}
│ @@ -604,23 +604,23 @@
│     600: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN8stlp_std13_Filebuf_base7_M_openEPKci
│     601: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z7GDTracejRKN8stlp_std12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPKcz
│     602: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN4GDIO7IOUtils10FileDeleteERKN8stlp_std12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
│     603: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN9gscore_v16errors7gsErrorC2ERKN8stlp_std12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEERKj
│     604: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN9gscore_v16errors7gsError20UN_RECOVERABLE_ERRORE
│     605: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN9gscore_v16errors14FileOpenFailed8ERR_NAMEE
│     606: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN9gscore_v16errors7gsErrorC2ERKS1_
│ -   607: 00000000     4 OBJECT  WEAK   HIDDEN   480 DW.ref._ZTIN5boost16bad_lexical_castE
│ +   607: 00000000     4 OBJECT  WEAK   HIDDEN   482 DW.ref._ZTIN5boost16bad_lexical_castE
│     608: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND pthread_spin_destroy
│     609: 00000000   290 FUNC    WEAK   DEFAULT  426 _ZN8stlp_std12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEj
│     610: 00000000    90 FUNC    WEAK   DEFAULT  428 _ZNK8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE16_M_append_bufferEv
│     611: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN8stlp_std13_Filebuf_base7_M_seekEli
│     612: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN8stlp_std13_Filebuf_base12_M_file_sizeEv
│     613: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN8stlp_std10_UnderflowIcNS_11char_traitsIcEEE7_M_doitEPNS_13basic_filebufIcS2_EE
│     614: 00000000   200 FUNC    WEAK   DEFAULT  459 _ZN8stlp_std13basic_filebufIcNS_11char_traitsIcEEE12_M_seek_initEb
│     615: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _Znaj
│     616: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZdaPv
│     617: 00000000   293 FUNC    WEAK   DEFAULT  465 _ZN8stlp_std12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEjc
│     618: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __dso_handle
│     619: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_atexit
│     620: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND pthread_spin_init
│ -   621: 00000000     4 OBJECT  WEAK   HIDDEN   482 DW.ref.__gxx_personality_v0
│ +   621: 00000000     4 OBJECT  WEAK   HIDDEN   480 DW.ref.__gxx_personality_v0
│     622: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __gxx_personality_v0


├── readelf --wide --relocs {}
│ @@ -11459,14 +11459,14 @@
│  00000b60  0000b201 R_386_32               00000000   .text._ZN8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE10_M_xsputncEci
│  00000b64  0000b201 R_386_32               00000000   .text._ZN8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE10_M_xsputncEci
│  00000b70  0000b201 R_386_32               00000000   .text._ZN8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE10_M_xsputncEci
│  00000b74  0000b201 R_386_32               00000000   .text._ZN8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE10_M_xsputncEci
│  00000b78  0000b201 R_386_32               00000000   .text._ZN8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE10_M_xsputncEci
│  00000b7c  0000b201 R_386_32               00000000   .text._ZN8stlp_std15basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE10_M_xsputncEci
│  
│ -Relocation section '.rel.data.DW.ref._ZTIN5boost16bad_lexical_castE' at offset 0x88cd8 contains 1 entry:
│ +Relocation section '.rel.data.DW.ref.__gxx_personality_v0' at offset 0x88cd8 contains 1 entry:
│   Offset     Info    Type                Sym. Value  Symbol's Name
│ -00000000  0001ea01 R_386_32               00000000   _ZTIN5boost16bad_lexical_castE
│ +00000000  00026e01 R_386_32               00000000   __gxx_personality_v0
│  
│ -Relocation section '.rel.data.DW.ref.__gxx_personality_v0' at offset 0x88ce0 contains 1 entry:
│ +Relocation section '.rel.data.DW.ref._ZTIN5boost16bad_lexical_castE' at offset 0x88ce0 contains 1 entry:
│   Offset     Info    Type                Sym. Value  Symbol's Name
│ -00000000  00026e01 R_386_32               00000000   __gxx_personality_v0
│ +00000000  0001ea01 R_386_32               00000000   _ZTIN5boost16bad_lexical_castE


├── readelf --wide --decompress --hex-dump=.shstrtab {}
│ @@ -778,15 +778,15 @@
│    0x00003070 6c2e6465 6275675f 6672616d 65002e72 l.debug_frame..r
│    0x00003080 656c2e65 685f6672 616d6500 2e72656c el.eh_frame..rel
│    0x00003090 2e646562 75675f70 75626e61 6d657300 .debug_pubnames.
│    0x000030a0 2e72656c 2e646562 75675f61 72616e67 .rel.debug_arang
│    0x000030b0 6573002e 72656c2e 64656275 675f7261 es..rel.debug_ra
│    0x000030c0 6e676573 002e6465 6275675f 73747200 nges..debug_str.
│    0x000030d0 2e72656c 2e646174 612e4457 2e726566 .rel.data.DW.ref
│ -  0x000030e0 2e5f5a54 494e3562 6f6f7374 31366261 ._ZTIN5boost16ba
│ -  0x000030f0 645f6c65 78696361 6c5f6361 73744500 d_lexical_castE.
│ -  0x00003100 2e72656c 2e646174 612e4457 2e726566 .rel.data.DW.ref
│ -  0x00003110 2e5f5f67 78785f70 6572736f 6e616c69 .__gxx_personali
│ -  0x00003120 74795f76 30002e6e 6f74652e 474e552d ty_v0..note.GNU-
│ +  0x000030e0 2e5f5f67 78785f70 6572736f 6e616c69 .__gxx_personali
│ +  0x000030f0 74795f76 30002e72 656c2e64 6174612e ty_v0..rel.data.
│ +  0x00003100 44572e72 65662e5f 5a54494e 35626f6f DW.ref._ZTIN5boo
│ +  0x00003110 73743136 6261645f 6c657869 63616c5f st16bad_lexical_
│ +  0x00003120 63617374 45002e6e 6f74652e 474e552d castE..note.GNU-
│    0x00003130 73746163 6b002e63 6f6d6d65 6e74002e stack..comment..
│    0x00003140 67726f75 7000                       group.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...