glibc_version_header icon indicating copy to clipboard operation
glibc_version_header copied to clipboard

Differences between architectures

Open willox opened this issue 6 years ago • 9 comments

I'm not quite 100% on this, but it seems that the generated files are only valid for the architecture glibc is built for by the Python script. This seems like a reasonable limitation, but there's seemingly no way to generate headers that will work for i386 or i686 builds.

I tried changing the Python script to cross-build glibc, but failed. I then tried executing the script on an i686 system, but also failed (a successful build, but hitting the duplicate symbols exception this time.)

Any ideas on this? I'll attach an example of a program that fails to link with a header that has been generated from a x86-64 build of glibc.


Example Download

The example assumes you've got an install of gcc that'll default to 64-bit compilation, but allows for the -m32 flag.

If you execute compile_x64, it should succeed and build the binary. If you execute compile_x32, it should fail with undefined reference to 'puts@GLIBC_2.2.5'. I believe it should actually be using puts@GLIBC_2.0 here.

willox avatar Aug 07 '18 13:08 willox

@willox I was trying to do the same, and also run into duplicated symbols exception:

Exception: duplicate incompatible symbol versions found: [u'__finite@@GLIBC_2.1', u'__finitef@@GLIBC_2.1', u'__finitel@@GLIBC_2.1', u'pwrite64@@GLIBC_2.2', u'open64@@GLIBC_2.2', u'pread@@GLIBC_2.2', u'pwrite@@GLIBC_2.2', u'lseek64@@GLIBC_2.2', u'pread64@@GLIBC_2.2', u'__pwrite64@@GLIBC_2.2', u'__pread64@@GLIBC_2.2']

@wheybags any advice?

SSE4 avatar Aug 30 '18 06:08 SSE4

@SSE4 did you manage to get cross-compilations working? I'm willing to put in some more effort if I don't need to jump on an i386 machine to try it out.

willox avatar Aug 30 '18 17:08 willox

@willox unfortunately, no, running into various issues. will try tomorrow again and let you know.

SSE4 avatar Aug 31 '18 15:08 SSE4

@SSE4 is that from modifying the build script to build glibc in 32 bit? If so, my only advice would be to looks at what object files those multiple definitions are coming from, and try use mailing lists/git hostory to figure out why thery're there (eg like the pthreads funcs in libpthread.so and libc.so for magic lock removal when running single threaded). As for 32 bit support in general, I never tried it, I will add it to the readme now. If someone gets this working for 32 bit builds, I'd happily accept a PR.

wheybags avatar Sep 04 '18 06:09 wheybags

some update:

  1. create PR with my in progress work #14
  2. create docker image I am using to cross-compiling: https://github.com/bincrafters/docker-glibc-builder https://hub.docker.com/r/bincrafters/docker-glibc-builder/ please lemme know if I've missed something I'll post my results here later today

SSE4 avatar Sep 14 '18 12:09 SSE4

for version 2.5 - 2.10.2 I am getting:

/tmp/cczxgbB4.s: Assembler messages:
/tmp/cczxgbB4.s: Error: open CFI at the end of file; missing .cfi_endproc directive
/tmp/cczxgbB4.s: Error: open CFI at the end of file; missing .cfi_endproc directive
make[2]: *** [/host/conan/glibc_version_header/builds/glibc-2.5/build/csu/crti.o] Error 1

for 2.11.3 I've got:

Exception: duplicate incompatible symbol versions found:
 {'pwrite': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'open64': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'__finite': ('libm-2.11.3.so', 'libc-2.11.3.so'), 
'__finitel': ('libm-2.11.3.so', 'libc-2.11.3.so'), 
'__pread64': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'pread64': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'pwrite64': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'pread': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'__finitef': ('libm-2.11.3.so', 'libc-2.11.3.so'), 
'lseek64': ('libpthread-2.11.3.so', 'libc-2.11.3.so'), 
'__pwrite64': ('libpthread-2.11.3.so', 'libc-2.11.3.so')}

for 2.25:

Exception: duplicate incompatible symbol versions found: 
{'pwrite': ('libpthread-2.25.so', 'libc-2.25.so'), 
'open64': ('libpthread-2.25.so', 'libc-2.25.so'), 
'__finite': ('libm-2.25.so', 'libc-2.25.so'), 
'__finitel': ('libm-2.25.so', 'libc-2.25.so'), 
'__pread64': ('libpthread-2.25.so', 'libc-2.25.so', 'librt.so', 'librt-2.25.so'), 
'pread64': ('libpthread-2.25.so', 'libc-2.25.so'), 
'pwrite64': ('libpthread-2.25.so', 'libc-2.25.so'), 
'pread': ('libpthread-2.25.so', 'libc-2.25.so'), 
'__finitef': ('libm-2.25.so', 'libc-2.25.so'), 
'lseek64': ('libpthread-2.25.so', 'libc-2.25.so'), 
'__pwrite64': ('libpthread-2.25.so', 'libc-2.25.so', 'librt.so', 'librt-2.25.so')}

for 2.26 and upper I am getting:

*** These critical programs are missing or too old: GNU ld compiler
*** Check the INSTALL file for required versions.

(for 2.26 I'll try to use newer versions of programs later)

SSE4 avatar Sep 15 '18 13:09 SSE4

okay, I think I've solved a problem with cfi_endproc (found patch that fixes an issue), and got the same list of duplicated symbols

SSE4 avatar Sep 15 '18 16:09 SSE4

@willox @wheybags I think I was finally able to make it working on x86, please review https://github.com/wheybags/glibc_version_header/pull/14

SSE4 avatar Nov 06 '18 14:11 SSE4

Hello, Have you successfully built and compiled ".so" libs cross different systems ( .,i,e: different gcc version) ? I investigated hard on this but failed at all. Which a lot of errors like: undefined reference to `VTT for std::__cxx11::basic_ostringstream<char, std::char_traits, std::allocator >@GLIBCXX_3.4.21' This error comes from the incompatible gcc version. any advice is really appreciated. Thank you

quocnhat avatar Jul 20 '20 07:07 quocnhat