Project

General

Profile

Bug #3722

link-editor is over restrictive of R_AMD64_32 addends

Added by Richard PALO over 7 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
2013-04-17
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

as suspected in https://www.illumos.org/issues/3616#note-18, this seems to confirm an issue in this new build of the solaris link loader... with gcc 4.7.2

http://sourceforge.net/projects/cppcheck/files/cppcheck/1.59/

richard@devzoneX:~/src/cppcheck-1.59$ gmake -j 6
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/check64bit.o lib/check64bit.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkassignif.o lib/checkassignif.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkautovariables.o lib/checkautovariables.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkboost.o lib/checkboost.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkbufferoverrun.o lib/checkbufferoverrun.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkclass.o lib/checkclass.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkexceptionsafety.o lib/checkexceptionsafety.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkinternal.o lib/checkinternal.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkio.o lib/checkio.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkleakautovar.o lib/checkleakautovar.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkmemoryleak.o lib/checkmemoryleak.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checknonreentrantfunctions.o lib/checknonreentrantfunctions.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checknullpointer.o lib/checknullpointer.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkobsoletefunctions.o lib/checkobsoletefunctions.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkother.o lib/checkother.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkpostfixoperator.o lib/checkpostfixoperator.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkstl.o lib/checkstl.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkuninitvar.o lib/checkuninitvar.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkunusedfunctions.o lib/checkunusedfunctions.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/checkunusedvar.o lib/checkunusedvar.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/cppcheck.o lib/cppcheck.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/errorlogger.o lib/errorlogger.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/executionpath.o lib/executionpath.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/mathlib.o lib/mathlib.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/path.o lib/path.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/preprocessor.o lib/preprocessor.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/settings.o lib/settings.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/suppressions.o lib/suppressions.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/symboldatabase.o lib/symboldatabase.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/templatesimplifier.o lib/templatesimplifier.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/timer.o lib/timer.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/token.o lib/token.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/tokenize.o lib/tokenize.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -c -o lib/tokenlist.o lib/tokenlist.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/cmdlineparser.o cli/cmdlineparser.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/cppcheckexecutor.o cli/cppcheckexecutor.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/filelister.o cli/filelister.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/main.o cli/main.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/pathmatch.o cli/pathmatch.cpp
g++  -O2 -DNDEBUG -Wall -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/threadexecutor.o cli/threadexecutor.cpp
g++ -O2 -DNDEBUG -Wall   -c -o externals/tinyxml/tinyxml2.o externals/tinyxml/tinyxml2.cpp
g++  -O2 -DNDEBUG -Wall -o cppcheck cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/main.o cli/pathmatch.o cli/threadexecutor.o lib/check64bit.o lib/checkassignif.o lib/checkautovariables.o lib/checkboost.o lib/checkbufferoverrun.o lib/checkclass.o lib/checkexceptionsafety.o lib/checkinternal.o lib/checkio.o lib/checkleakautovar.o lib/checkmemoryleak.o lib/checknonreentrantfunctions.o lib/checknullpointer.o lib/checkobsoletefunctions.o lib/checkother.o lib/checkpostfixoperator.o lib/checkstl.o lib/checkuninitvar.o lib/checkunusedfunctions.o lib/checkunusedvar.o lib/cppcheck.o lib/errorlogger.o lib/executionpath.o lib/mathlib.o lib/path.o lib/preprocessor.o lib/settings.o lib/suppressions.o lib/symboldatabase.o lib/templatesimplifier.o lib/timer.o lib/token.o lib/tokenize.o lib/tokenlist.o externals/tinyxml/tinyxml2.o  
ld: fatal: relocation error: R_AMD64_32: file externals/tinyxml/tinyxml2.o: symbol .LC8: value 0x805ab5ca does not fit
ld: fatal: relocation error: R_AMD64_32: file externals/tinyxml/tinyxml2.o: symbol .LC9: value 0x805ab5be does not fit
collect2: error: ld returned 1 exit status
gmake: *** [cppcheck] Error 1
richard@devzoneX:~/src/cppcheck-1.59$ g++  -O2 -DNDEBUG -Wall -o cppcheck cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/main.o cli/pathmatch.o cli/threadexecutor.o lib/check64bit.o lib/checkassignif.o lib/checkautovariables.o lib/checkboost.o lib/checkbufferoverrun.o lib/checkclass.o lib/checkexceptionsafety.o lib/checkinternal.o lib/checkio.o lib/checkleakautovar.o lib/checkmemoryleak.o lib/checknonreentrantfunctions.o lib/checknullpointer.o lib/checkobsoletefunctions.o lib/checkother.o lib/checkpostfixoperator.o lib/checkstl.o lib/checkuninitvar.o lib/checkunusedfunctions.o lib/checkunusedvar.o lib/cppcheck.o lib/errorlogger.o lib/executionpath.o lib/mathlib.o lib/path.o lib/preprocessor.o lib/settings.o lib/suppressions.o lib/symboldatabase.o lib/templatesimplifier.o lib/timer.o lib/token.o lib/tokenize.o lib/tokenlist.o externals/tinyxml/tinyxml2.o -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/lto-wrapper
Target: x86_64-sun-solaris2.11
Configured with: ../gcc-4.7.2/configure --enable-languages='c obj-c++ objc go fortran c++' --enable-shared --enable-long-long --with-local-prefix=/opt/pkg/gcc47 --enable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/opt/pkg/lib ' --disable-nls --enable-__cxa_atexit --with-gxx-include-dir=/opt/pkg/gcc47/include/c++/ --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/opt/pkg/bin/gas --prefix=/opt/pkg/gcc47 --build=x86_64-sun-solaris2.11 --host=x86_64-sun-solaris2.11 --infodir=/opt/pkg/gcc47/info --mandir=/opt/pkg/gcc47/man
Thread model: posix
gcc version 4.7.2 (GCC) 
COMPILER_PATH=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/:/usr/ccs/bin/
LIBRARY_PATH=/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib/amd64/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../amd64/:/lib/amd64/:/usr/lib/amd64/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-O2' '-D' 'NDEBUG' '-Wall' '-o' 'cppcheck' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/collect2 -V -Y P,/lib/amd64:/usr/lib/amd64 -Qy -o cppcheck /usr/lib/amd64/crt1.o /usr/lib/amd64/crti.o /usr/lib/amd64/values-Xa.o /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/crtbegin.o -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib/amd64 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../amd64 -L/lib/amd64 -L/usr/lib/amd64 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../.. -R /opt/pkg/gcc47/x86_64-sun-solaris2.11/lib/amd64 -R /opt/pkg/gcc47/lib/amd64 cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/main.o cli/pathmatch.o cli/threadexecutor.o lib/check64bit.o lib/checkassignif.o lib/checkautovariables.o lib/checkboost.o lib/checkbufferoverrun.o lib/checkclass.o lib/checkexceptionsafety.o lib/checkinternal.o lib/checkio.o lib/checkleakautovar.o lib/checkmemoryleak.o lib/checknonreentrantfunctions.o lib/checknullpointer.o lib/checkobsoletefunctions.o lib/checkother.o lib/checkpostfixoperator.o lib/checkstl.o lib/checkuninitvar.o lib/checkunusedfunctions.o lib/checkunusedvar.o lib/cppcheck.o lib/errorlogger.o lib/executionpath.o lib/mathlib.o lib/path.o lib/preprocessor.o lib/settings.o lib/suppressions.o lib/symboldatabase.o lib/templatesimplifier.o lib/timer.o lib/token.o lib/tokenize.o lib/tokenlist.o externals/tinyxml/tinyxml2.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/crtend.o /usr/lib/amd64/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1741 (illumos)
ld: fatal: relocation error: R_AMD64_32: file externals/tinyxml/tinyxml2.o: symbol .LC8: value 0x805ab5ca does not fit
ld: fatal: relocation error: R_AMD64_32: file externals/tinyxml/tinyxml2.o: symbol .LC9: value 0x805ab5be does not fit
collect2: error: ld returned 1 exit status

History

#1

Updated by Richard PALO over 7 years ago

on a sidenote, I might add that cppcheck could be useful for the illumos build system, that is cppchecking seems to find a number of potential issues in the illumos source tree.
the bits are GPLv3.

#2

Updated by Rich Lowe over 7 years ago

You have 3 GCC's:

- 1. 4.7.2 defaulting 64bit (evidenced in the first paste)
- 2. 4.4.4 defaulting 32bit (the second paste)
- 3. 4.7.2 defaulting 32bit (the third paste)

The distinction between pastes #1 and #3 is not the link-editor version, it is that in the latter the compiler's producing a 32bit executable. This isn't the fault of #3616 et al.

#3

Updated by Rich Lowe over 7 years ago

  • Subject changed from ld: fatal: relocation error: R_AMD64_32 : gcc4.7.2 and Solaris Link Editors: 5.11-1.1741 (illumos) to link-editor is over restrictive of R_AMD64_32 addends

I updated the description and synopsis to reflect what I think is going on. We're claiming that the addend for the R_AMD64_32 relocations in question won't fit. However, that value does fit in a uint32_t (though it'd overflow a signed int32_t). I suspect we're being overly restrictive.

As a workaround, you can compile your application with '-fPIC', which will avoid writing text at runtime, and prevent us generating the currently problematic relocations.

#4

Updated by Richard PALO over 7 years ago

Rich Lowe wrote:

You have 3 GCC's:

- 1. 4.7.2 defaulting 64bit (evidenced in the first paste)
- 2. 4.4.4 defaulting 32bit (the second paste)
- 3. 4.7.2 defaulting 32bit (the third paste)

The distinction between pastes #1 and #3 is not the link-editor version, it is that in the latter the compiler's producing a 32bit executable. This isn't the fault of #3616 et al.

You are so right, I'm spoiled that in pkgsrc, if the ABI=64 (as in my case) it automatically does the right thing...

didn't change anything for omnios:

richard@omni1:~/src/cppcheck-1.59$ gmake clean
rm -f build/*.o lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner reduce cppcheck cppcheck.1
richard@omni1:~/src/cppcheck-1.59$ export CXXFLAGS="-m64" 
richard@omni1:~/src/cppcheck-1.59$ gmake -j 6
g++  -m64 -Ilib -c -o lib/check64bit.o lib/check64bit.cpp
g++  -m64 -Ilib -c -o lib/checkassignif.o lib/checkassignif.cpp
g++  -m64 -Ilib -c -o lib/checkautovariables.o lib/checkautovariables.cpp
g++  -m64 -Ilib -c -o lib/checkboost.o lib/checkboost.cpp
g++  -m64 -Ilib -c -o lib/checkbufferoverrun.o lib/checkbufferoverrun.cpp
g++  -m64 -Ilib -c -o lib/checkclass.o lib/checkclass.cpp
g++  -m64 -Ilib -c -o lib/checkexceptionsafety.o lib/checkexceptionsafety.cpp
g++  -m64 -Ilib -c -o lib/checkinternal.o lib/checkinternal.cpp
g++  -m64 -Ilib -c -o lib/checkio.o lib/checkio.cpp
g++  -m64 -Ilib -c -o lib/checkleakautovar.o lib/checkleakautovar.cpp
g++  -m64 -Ilib -c -o lib/checkmemoryleak.o lib/checkmemoryleak.cpp
g++  -m64 -Ilib -c -o lib/checknonreentrantfunctions.o lib/checknonreentrantfunctions.cpp
g++  -m64 -Ilib -c -o lib/checknullpointer.o lib/checknullpointer.cpp
g++  -m64 -Ilib -c -o lib/checkobsoletefunctions.o lib/checkobsoletefunctions.cpp
g++  -m64 -Ilib -c -o lib/checkother.o lib/checkother.cpp
g++  -m64 -Ilib -c -o lib/checkpostfixoperator.o lib/checkpostfixoperator.cpp
g++  -m64 -Ilib -c -o lib/checkstl.o lib/checkstl.cpp
g++  -m64 -Ilib -c -o lib/checkuninitvar.o lib/checkuninitvar.cpp
g++  -m64 -Ilib -c -o lib/checkunusedfunctions.o lib/checkunusedfunctions.cpp
g++  -m64 -Ilib -c -o lib/checkunusedvar.o lib/checkunusedvar.cpp
g++  -m64 -Ilib -c -o lib/cppcheck.o lib/cppcheck.cpp
g++  -m64 -Ilib -c -o lib/errorlogger.o lib/errorlogger.cpp
g++  -m64 -Ilib -c -o lib/executionpath.o lib/executionpath.cpp
g++  -m64 -Ilib -c -o lib/mathlib.o lib/mathlib.cpp
g++  -m64 -Ilib -c -o lib/path.o lib/path.cpp
g++  -m64 -Ilib -c -o lib/preprocessor.o lib/preprocessor.cpp
g++  -m64 -Ilib -c -o lib/settings.o lib/settings.cpp
g++  -m64 -Ilib -c -o lib/suppressions.o lib/suppressions.cpp
g++  -m64 -Ilib -c -o lib/symboldatabase.o lib/symboldatabase.cpp
g++  -m64 -Ilib -c -o lib/templatesimplifier.o lib/templatesimplifier.cpp
g++  -m64 -Ilib -c -o lib/timer.o lib/timer.cpp
g++  -m64 -Ilib -c -o lib/token.o lib/token.cpp
g++  -m64 -Ilib -c -o lib/tokenize.o lib/tokenize.cpp
g++  -m64 -Ilib -c -o lib/tokenlist.o lib/tokenlist.cpp
g++  -m64 -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/cmdlineparser.o cli/cmdlineparser.cpp
g++  -m64 -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/cppcheckexecutor.o cli/cppcheckexecutor.cpp
g++  -m64 -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/filelister.o cli/filelister.cpp
g++  -m64 -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/main.o cli/main.cpp
g++  -m64 -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/pathmatch.o cli/pathmatch.cpp
g++  -m64 -Ilib -Iexternals -Iexternals/tinyxml -c -o cli/threadexecutor.o cli/threadexecutor.cpp
g++ -m64   -c -o externals/tinyxml/tinyxml2.o externals/tinyxml/tinyxml2.cpp
g++  -m64 -o cppcheck cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/main.o cli/pathmatch.o cli/threadexecutor.o lib/check64bit.o lib/checkassignif.o lib/checkautovariables.o lib/checkboost.o lib/checkbufferoverrun.o lib/checkclass.o lib/checkexceptionsafety.o lib/checkinternal.o lib/checkio.o lib/checkleakautovar.o lib/checkmemoryleak.o lib/checknonreentrantfunctions.o lib/checknullpointer.o lib/checkobsoletefunctions.o lib/checkother.o lib/checkpostfixoperator.o lib/checkstl.o lib/checkuninitvar.o lib/checkunusedfunctions.o lib/checkunusedvar.o lib/cppcheck.o lib/errorlogger.o lib/executionpath.o lib/mathlib.o lib/path.o lib/preprocessor.o lib/settings.o lib/suppressions.o lib/symboldatabase.o lib/templatesimplifier.o lib/timer.o lib/token.o lib/tokenize.o lib/tokenlist.o externals/tinyxml/tinyxml2.o  
richard@omni1:~/src/cppcheck-1.59$ file cppcheck
cppcheck:       ELF 64-bit LSB executable AMD64 Version 1, dynamically linked, not stripped, no debugging information available

Will check with your suggestion and post back...

#5

Updated by Richard PALO over 7 years ago

You suggestion of using "-fPIC" seems to work as you expected.

I'll therefore add a hack.mk in the meanwhile setting this in CPPFLAGS for this specific version of the solaris linker (I do presume that only 1741 is affected)...

Thanks again Rich for your prompt observations...
I'm sure I'm not alone in considering your linker work extremely valuable.

cheers

#6

Updated by Rich Lowe over 7 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 50
  • Tags deleted (needs-triage)

The theory that we're being too strict to R_AMD64_32 addends is accurate. In the amd64 do_reloc_* implementations, we're mandating that the low 31 bits are non-0, and thus forbidding a bunch of perfectly valid addends. For R_AMD64_32, which is unsigned, we obviously only care that no bit greater than 32 is set... (our handling of R_AMD64_32S seems correct and is presumably ultimately why R_AMD64_32 is broken).

#7

Updated by Rich Lowe over 7 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100

Resolved in 6136c58

Also available in: Atom PDF