Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Trac
Trac
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Issue Boards

GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

  • Legacy
  • TracTrac
  • Issues
  • #6622

Closed (moved)
Open
Opened Aug 17, 2012 by Trac@tracbot

Tor link against static zlib broken by -pie switch

Build environment: CentOS v5.8/x86_64 with GCC v4.4.6.

I'm linking Tor against staticly-built versions of zlib (v1.2.7) and OpenSSL (v1.0.1c). This has always worked correctly with the 0.2.2.x versions of Tor. With version 0.2.3-20-rc the final link fails with this error:

$ gcc44 -m64 -O2 -g -march=native -mno-avx -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -fwrapv --param ssp-buffer-size=1 -fPIE -Wall -fno-strict-aliasing -L/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib -pie -z relro -z now -o tor tor_main.o ./libtor.a ../common/libor.a ../common/libor-crypto.a ../common/libor-event.a /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libz.a -lm /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libevent.a /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libssl.a /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libcrypto.a /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libz.a -ldl -lrt /usr/bin/ld: /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libz.a(deflate.o): relocation R_X86_64_32S against `_length_code' can not be used when making a shared object; recompile with -fPIC /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libz.a: could not read symbols: Bad value

Removing that -pie switch allows the link to complete successfully.

The GCC doc suggests that the linking error is due to not having used -pie during compilation. This seems to be true as neither zlib nor openssl nor libevent are compiled with this switch (or with -fPIC). Not even the Tor source is compiled with -pie. It is used nowhere until that final link.

The offending symbol is defined in zlib's deflate.c, which is compiled with this command line:

gcc44 -m64 -O2 -g -march=native -mno-avx -c -o deflate.o deflate.c

Do we really need this -pie switch when linking Tor? What is the adverse impact if I just remove it from the linker input?

Trac:
Username: tmpname0901

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
Tor: unspecified
Milestone
Tor: unspecified
Assign milestone
Time tracking
None
Due date
None
Reference: legacy/trac#6622