Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3947492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:15:28+00:00 2026-05-20T01:15:28+00:00

In Linux, why are stubs required for standard libraries?

  • 0

In Linux, why are stubs required for standard libraries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:15:28+00:00Added an answer on May 20, 2026 at 1:15 am

    stubs are required to ensure proper linking of an executable across various linux releases without building the object files.

    For example:
    Let a be the executable we are building:

    gcc -o a test.o test1.o test2.o -lz
    

    In the above case executable a has a dependency on the libz.so (-lz is to link with libz.so). The linker resolves libz.so using the LD_LIBRARY_PATH.

    Now let us see the problem:

    In RHEL4(Linux Zseries):
    objdump -T /usr/lib64/libz.so.1 | grep stack_chk 
    
    In RHEL5(Linux ZSeries);
    objdump -T /usr/lib64/libz.so.1 | grep stack_chk
    
    0000000000000000 DF UND 0000000000000031 GLIBC_2.4 __stack_chk_fail 
    

    In RHEL5, we see an undefined symbol in the libz.so.
    Unless we pass libc to the linker after lz in the above command, this cannot be resolved.

    Stubs:
    If we generate the stub for libz.so, packing all the symbols of libz.so in to a stub library and link with the stub library instead of the real library, we don’t see any errors:

    Modified link line:

    gcc -o a test.o test1.o test2.o -L/home/lib/stubs/ -lz
    

    In the /home/lib/stubs directory, we have a stub library for libz.so by name libzstub.so.

    Linker gives higher priority to the path given in the link command than LD_LIBRARY_PATH.

    Now even if we link in the RHEL5 release, the linker resolves the symbols for the libz.so from the /home/lib/stubs directory.

    Here the configuration details of the boxes i have used.

    Loader takes care of loading the coresponding function at runtime.

    RHEL5:

    libcmpiutil-0.4-2.el5
    glibc-utils-2.5-42
    libc-client-2004g-2.2.1
    libcap-1.10-26
    libcap-1.10-26
    libchewing-devel-0.3.0-8.el5
    libchewing-0.3.0-8.el5
    libcxgb3-1.2.3-1.el5
    libcap-devel-1.10-26
    glibc-common-2.5-42
    libcxgb3-static-1.2.3-1.el5
    libcroco-devel-0.6.1-2.1
    compat-glibc-headers-2.3.4-2.26
    libcroco-0.6.1-2.1
    compat-libcom_err-1.0-7
    libcmpiutil-devel-0.4-2.el5
    compat-glibc-2.3.4-2.26
    glibc-headers-2.5-42
    glibc-devel-2.5-42
    libcap-devel-1.10-26
    libc-client-2004g-2.2.1
    libcmpiutil-0.4-2.el5
    libcroco-0.6.1-2.1
    libc-client-devel-2004g-2.2.1
    glibc-2.5-42
    libchewing-devel-0.3.0-8.el5
    libcroco-devel-0.6.1-2.1
    compat-libcom_err-1.0-7
    libc-client-devel-2004g-2.2.1
    libchewing-0.3.0-8.el5
    libcxgb3-1.2.3-1.el5
    libcmpiutil-devel-0.4-2.el5
    glibc-2.5-42
    glibc-devel-2.5-42
    compat-glibc-2.3.4-2.26
    

    RHEL4:

    rpm -qa | grep libc
    glibc-2.3.4-2.41
    libcxgb3-1.1.4-1.el4
    libc-client-2002e-14
    libcroco-0.6.0-4
    libcap-devel-1.10-20
    glibc-kernheaders-2.4-9.1.103.EL
    compat-libcom_err-1.0-5
    glibc-devel-2.3.4-2.41
    compat-glibc-2.3.2-95.30
    compat-libcom_err-1.0-5
    glibc-common-2.3.4-2.41
    libcroco-devel-0.6.0-4
    libcxgb3-1.1.4-1.el4
    libc-client-2002e-14
    glibc-utils-2.3.4-2.41
    libcap-1.10-20
    glibc-headers-2.3.4-2.41
    glibc-profile-2.3.4-2.41
    libcxgb3-static-1.1.4-1.el4
    glibc-devel-2.3.4-2.41
    compat-glibc-2.3.2-95.30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Linux provides the stime(2) call to set the system time. However, while this will
On linux, it's possible to create a tun interface using a tun driver which
In Linux, what is the difference between /dev/ttyS0 and /dev/ttys0 ? I know that
On Linux/NPTL , threads are created as some kind of process. I can see
Under Linux, my C++ application is using fork() and execv() to launch multiple instances
On Linux (or Solaris) is there a better way than hand parsing /proc/self/maps repeatedly
Does Linux/Unix/Posix provide an API to user-space applications to access a monotonically increasing clock,
In Linux When I invoke python from the shell it replicates its environment, and
On Linux, how can I (programmatically) retrieve the following counters on a per-interface basis
On Linux, feenableexcept and fedisableexcept can be used to control the generation of SIGFPE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.