Search code examples
compilationglibc

what is the difference between .o and .os objs in glibc


I am studying the source code of glibc. I found when compiling glibc I get some .o objs and some .os objs. E.g., there is a dl-load.o, as well as a dl-load.os. So, what is the difference between them?

Thank you! Yiming


Solution

  • SETUP: glibc2.3.4

    EXPERIMENT

    First, nm on glibc/bld/close.{o,os} shows that only close.o has syscall_error defined. Then, write a simple program to detect whether syscall_error is used in close().

    #include <unistd.h>
    #include <stdio.h>
    int main() { 
        return close(fileno(stdin));
    }
    
    gcc -o s.out -static -g a.c
    gcc -o d.out -g a.c
    

    RESULT

    gdb shows that only close() in s.out make use of syscall_error. Thus .o file is for static library while .os is for dynamic library.