ctemplate icon indicating copy to clipboard operation
ctemplate copied to clipboard

build with >=gcc-7.1 failed

Open andy9a9 opened this issue 5 years ago • 10 comments

After switching to newer gcc, some errors popped up.

compilation...
.../8.2.0/ld: ./.libs/libctemplate_nothreads.so: invalid string offset 40616 >= 40380 for section `.strtab'
.../8.2.0/ld: ./.libs/libctemplate_nothreads.so: invalid string offset 40412 >= 40380 for section `.strtab'
.../8.2.0/ld: ./.libs/libctemplate_nothreads.so: invalid string offset 40493 >= 40380 for section `.strtab'
.../8.2.0/ld: ./.libs/libctemplate_nothreads.so: invalid string offset 40616 >= 40380 for section `.strtab'
.../8.2.0/ld: ./.libs/libctemplate_nothreads.so: invalid string offset 40412 >= 40380 for section `.strtab'
.../8.2.0/ld: ./.libs/libctemplate_nothreads.so: invalid string offset 40493 >= 40380 for section `.strtab'

Looks like, that .strtab section is on different place.

objdump -dj .strtab libctemplate_nothreads.so.3.0.0 
libctemplate_nothreads.so.3.0.0:     file format elf32-littlearm

objdump: libctemplate_nothreads.so.3.0.0: invalid string offset 40616 >= 40380 for section `.strtab'
objdump: libctemplate_nothreads.so.3.0.0: invalid string offset 40412 >= 40380 for section `.strtab'
objdump: libctemplate_nothreads.so.3.0.0: invalid string offset 40493 >= 40380 for section `.strtab'
objdump: section '.strtab' mentioned in a -j option, but not found in any input file

readelf -S

# compiled with gcc-8.2.0 

There are 37 section headers, starting at offset 0x43b9f4:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .note.gnu.build-i NOTE            00000114 000114 000024 00   A  0   0  4
  [ 2] .gnu.hash         GNU_HASH        00000138 000138 00155c 04   A  3   0  4
  [ 3] .dynsym           DYNSYM          00001694 001694 002320 10   A  4   3  4
  [ 4] .dynstr           STRTAB          000039b4 0039b4 009fdb 00   A  0   0  1
  [ 5] .gnu.version      VERSYM          0000d990 00d990 000464 02   A  3   0  2
  [ 6] .gnu.version_r    VERNEED         0000ddf4 00ddf4 0000f0 00   A  4   3  4
  [ 7] .rel.dyn          REL             0000dee4 00dee4 0010d0 08   A  3   0  4
  [ 8] .rel.plt          REL             0000efb4 00efb4 000970 08  AI  3  21  4
  [ 9] .init             PROGBITS        0000f924 00f924 00000c 00  AX  0   0  4
  [10] .plt              PROGBITS        0000f930 00f930 000e3c 04  AX  0   0  4
  [11] .text             PROGBITS        0001076c 01076c 024ad4 00  AX  0   0  4
  [12] .fini             PROGBITS        00035240 035240 000008 00  AX  0   0  4
  [13] .rodata           PROGBITS        00035248 035248 00d9c4 00   A  0   0  4
  [14] .ARM.extab        PROGBITS        00042c0c 042c0c 0013bc 00   A  0   0  4
  [15] .ARM.exidx        ARM_EXIDX       00043fc8 043fc8 000908 00  AL 11   0  4
  [16] .eh_frame         PROGBITS        000448d0 0448d0 000004 00   A  0   0  4
  [17] .init_array       INIT_ARRAY      00054a48 044a48 000024 04  WA  0   0  4
  [18] .fini_array       FINI_ARRAY      00054a6c 044a6c 000004 04  WA  0   0  4
  [19] .data.rel.ro      PROGBITS        00054a70 044a70 000490 00  WA  0   0  4
  [20] .dynamic          DYNAMIC         00054f00 044f00 000100 08  WA  4   0  4
  [21] .got              PROGBITS        00055000 045000 000640 04  WA  0   0  4
  [22] .data             PROGBITS        00055640 045640 00033c 00  WA  0   0  8
  [23] .bss              NOBITS          0005597c 04597c 000840 00  WA  0   0  4
  [24] .comment          PROGBITS        00000000 04597c 000011 01  MS  0   0  1
  [25] .ARM.attributes   ARM_ATTRIBUTES  00000000 04598d 000028 00      0   0  1
  [26] .debug_aranges    PROGBITS        00000000 0459b8 0007d8 00      0   0  8
  [27] .debug_info       PROGBITS        00000000 046190 19dbd1 00      0   0  1
  [28] .debug_abbrev     PROGBITS        00000000 1e3d61 00af19 00      0   0  1
  [29] .debug_line       PROGBITS        00000000 1eec7a 041031 00      0   0  1
  [30] .debug_frame      PROGBITS        00000000 22fcac 004644 00      0   0  4
  [31] .debug_str        PROGBITS        00000000 2342f0 103bef 01  MS  0   0  1
  [32] .debug_loc        PROGBITS        00000000 337edf 0d38fa 00      0   0  1
  [33] .debug_ranges     PROGBITS        00000000 40b7e0 024098 00      0   0  8
  [34] .symtab           SYMTAB          00000000 42f878 002250 10     35 138  4
  [35] .strtab           STRTAB          00000000 431ac8 009dbc 00      0   0  1
  [36] .shstrtab         STRTAB          00000000 43b884 00016d 00      0   0  1
# compiled with gcc-6.3.0

There are 38 section headers, starting at offset 0x363f88:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .note.gnu.build-i NOTE            00000114 000114 000024 00   A  0   0  4
  [ 2] .gnu.hash         GNU_HASH        00000138 000138 001740 04   A  3   0  4
  [ 3] .dynsym           DYNSYM          00001878 001878 0023b0 10   A  4   3  4
  [ 4] .dynstr           STRTAB          00003c28 003c28 009ce7 00   A  0   0  1
  [ 5] .gnu.version      VERSYM          0000d910 00d910 000476 02   A  3   0  2
  [ 6] .gnu.version_r    VERNEED         0000dd88 00dd88 0000f0 00   A  4   3  4
  [ 7] .rel.dyn          REL             0000de78 00de78 001010 08   A  3   0  4
  [ 8] .rel.plt          REL             0000ee88 00ee88 000968 08  AI  3  22  4
  [ 9] .init             PROGBITS        0000f7f0 00f7f0 00000c 00  AX  0   0  4
  [10] .plt              PROGBITS        0000f7fc 00f7fc 000e30 04  AX  0   0  4
  [11] .text             PROGBITS        0001062c 01062c 029634 00  AX  0   0  4
  [12] .fini             PROGBITS        00039c60 039c60 000008 00  AX  0   0  4
  [13] .rodata           PROGBITS        00039c68 039c68 00d9a4 00   A  0   0  4
  [14] .ARM.extab        PROGBITS        0004760c 04760c 0018b8 00   A  0   0  4
  [15] .ARM.exidx        ARM_EXIDX       00048ec4 048ec4 000968 00  AL 11   0  4
  [16] .eh_frame         PROGBITS        0004982c 04982c 000004 00   A  0   0  4
  [17] .init_array       INIT_ARRAY      00059a44 049a44 000024 04  WA  0   0  4
  [18] .fini_array       FINI_ARRAY      00059a68 049a68 000004 04  WA  0   0  4
-->  [19] .jcr              PROGBITS        00059a6c 049a6c 000004 00  WA  0   0  4
  [20] .data.rel.ro      PROGBITS        00059a70 049a70 000490 00  WA  0   0  4
  [21] .dynamic          DYNAMIC         00059f00 049f00 000100 08  WA  4   0  4
  [22] .got              PROGBITS        0005a000 04a000 0005dc 04  WA  0   0  4
  [23] .data             PROGBITS        0005a5e0 04a5e0 00033c 00  WA  0   0  8
  [24] .bss              NOBITS          0005a91c 04a91c 000840 00  WA  0   0  4
  [25] .comment          PROGBITS        00000000 04a91c 000011 01  MS  0   0  1
  [26] .ARM.attributes   ARM_ATTRIBUTES  00000000 04a92d 000028 00      0   0  1
  [27] .debug_aranges    PROGBITS        00000000 04a958 000798 00      0   0  8
  [28] .debug_info       PROGBITS        00000000 04b0f0 14ab2d 00      0   0  1
  [29] .debug_abbrev     PROGBITS        00000000 195c1d 0098e0 00      0   0  1
  [30] .debug_line       PROGBITS        00000000 19f4fd 0163dc 00      0   0  1
  [31] .debug_frame      PROGBITS        00000000 1b58dc 0045dc 00      0   0  4
  [32] .debug_str        PROGBITS        00000000 1b9eb8 106f6c 01  MS  0   0  1
  [33] .debug_loc        PROGBITS        00000000 2c0e24 07c621 00      0   0  1
  [34] .debug_ranges     PROGBITS        00000000 33d448 01a700 00      0   0  8
  [35] .symtab           SYMTAB          00000000 357b48 002290 10     36 144  4
  [36] .strtab           STRTAB          00000000 359dd8 00a03e 00      0   0  1
  [37] .shstrtab         STRTAB          00000000 363e16 000172 00      0   0  1

After comparing with working version (compiled with gcc 6.3.0) looks like, .jcr section is missing. After some googling, seems to be, that gcc support for Java is gone since version 7 gjc.

andy9a9 avatar Apr 04 '19 10:04 andy9a9

Are you mixing files build by different versions of compilers? How is this a libctemplate bug?

OlafvdSpek avatar Apr 04 '19 11:04 OlafvdSpek

Just for the introduction. I was using ctemplate with yocto build system (pyro branch). After upgrading to newer yocto system (thud), these errors have been showed. Pyro is using gcc-6.3.0 and Thud has new 8.2.0. So, I've just switched build system with new gcc, without ctemplate code change.

My comparison is between mentioned buildsystems.

andy9a9 avatar Apr 04 '19 11:04 andy9a9

Is this reproducible without Yocto, Pyro and Thud?

OlafvdSpek avatar Apr 04 '19 11:04 OlafvdSpek

I Have gcc-8.3.0 on Debian from scratch. Compilation was successful. So seems to, that is something related to yocto buildsystem. Do you have some idea, what could be wrong?

andy9a9 avatar Apr 04 '19 12:04 andy9a9

Nope

OlafvdSpek avatar Apr 04 '19 13:04 OlafvdSpek

After new testing, it's seems to be, that is relevant for cross-compiling, but not only for yocto. I have set-up new Debian machine and download arm-linux-gnueabi compiler. So it's reproducible.

See error.log

andy9a9 avatar Apr 08 '19 06:04 andy9a9

I'm no expert on automake, what would be required for cross-compiling and what could be wrong.

OlafvdSpek avatar Apr 09 '19 11:04 OlafvdSpek

After some testing, I have identified, that some symbols have been dropped from library. It sounds like, some of them are required.

_ZN3URL19HasInsecureProtocolEPKci
_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_
_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EE17_M_realloc_insertIJS7_EEEvN9__gnu_cxx17__normal_iteratorIPS7_S9_EEDpOT_
_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EED1Ev
_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EED2Ev
_ZNSt6vectorISt4pairIyiESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag
_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJOS5_EESJ_IJEEEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_
_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_
_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E
_ZSt13__adjust_heapIN9__gnu_cxx17__normal_iteratorIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS7_SaIS7_EEEEiS7_NS0_5__ops15_Iter_less_iterEEvT_T0_SG_T1_T2_
_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS7_SaIS7_EEEENS0_5__ops15_Iter_less_iterEEvT_SF_T0_
_ZSt25__unguarded_linear_insertIN9__gnu_cxx17__normal_iteratorIPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt6vectorIS7_SaIS7_EEEENS0_5__ops14_Val_less_iterEEvT_T0_
_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_RKS8_

Current list of required symbols:

CTEMPLATE_SYMBOLS = '(ctemplate|template_modifiers|BaseArena|UnsafeArena|[^A-Za-z]Template[^A-Za-z]|TemplateDictionary|TemplateNamelist|TemplateFromString|TemplateString|TemplateState|[^A-Za-z]Strip[^A-Za-z])'

[EDIT]: After some symbols enabling, seems to be, that I have found, the missing one. After adding forward_iterator and tree_iterator compilation was successful. There is still lot of warning similar to this one. (More info about deprecated iterators could be found here https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ ).

In file included from usr/include/c++/8.2.0/vector:69,
                 from ./src/ctemplate/template_cache.h:40,
                 from src/template_cache.cc:34:
usr/include/c++/8.2.0/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const std::pair<long long unsigned int, int>&}; _Tp = std::pair<long long unsigned int, int>; _Alloc = std::allocator<std::pair<long long unsigned int, int> >]':
usr/include/c++/8.2.0/bits/vector.tcc:413:7: note: parameter passing for argument of type 'std::vector<std::pair<long long unsigned int, int> >::iterator' {aka '__gnu_cxx::__normal_iterator<std::pair<long long unsigned int, int>*, std::vector<std::pair<long long unsigned int, int> > >'} changed in GCC 7.1
       vector<_Tp, _Alloc>::
       ^~~~~~~~~~~~~~~~~~~

Another question is, why are you removing some symbols from library? Probably when the toolchain is changed, you have to re-add new symbol. Isn't possible just remove this symbol polluting and keep linker do it yourself?

andy9a9 avatar Apr 12 '19 08:04 andy9a9

Hi @OlafvdSpek !

Did you have some time for thinking about it?

andy9a9 avatar May 12 '19 08:05 andy9a9

No, as I have no experience with cross-compiling.

OlafvdSpek avatar May 12 '19 15:05 OlafvdSpek