Why gcc-7.5.0 generate different relocation entry

I am studying elf relocation and note that in our school’s container, compile the c file below:

int sum(int *a, int n)
{
    return a[0]+a[1];
}

int array[2] = {1, 2};

int main()
{
    int val = sum(array, 2);
    return val;
}

the relocation entry type of the function sum is R_X86_64_PC32.
However when I try compiling the c file on another server, its type changes to R_X86_64_PLT32.
I don’t know which factor decides the type of relocation entry.The kernel version? Or the configure options?

The whole process of compiling the file on school’s container is:

$> gcc -v -c -o main.o main.c
Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'main.o' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -quiet -v -imultiarch x86_64-linux-gnu main.c -quiet -dumpbase main.c -mtune=generic -march=x86-64 -auxbase-strip main.o -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccSRwEz4.s
GNU C11 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C11 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: b62ed4a2880cd4159476ea8293b72fa8
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'main.o' '-mtune=generic' '-march=x86-64'
 as -v --64 -o main.o /tmp/ccSRwEz4.s
GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'main.o' '-mtune=generic' '-march=x86-64'

$> uname -a
Linux jupyter-10235101439 5.10.134-16.1.al8.x86_64 #1 SMP Thu Dec 7 14:11:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

On another server:

$> gcc -v -c -o main.o main.c
Using built-in specs.
COLLECT_GCC=./bin/gcc-7.5.0/bin/gcc
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0 --with-gmp=/home/jizimo/lib/gmp --with-mpfr=/home/jizimo/lib/mpfr --with-mpc=/home/jizimo/lib/mpc
Thread model: posix
gcc version 7.5.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'main.o' '-mtune=generic' '-march=x86-64'
 /home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/libexec/gcc/x86_64-pc-linux-gnu/7.5.0/cc1 -quiet -v -imultiarch x86_64-linux-gnu main.c -quiet -dumpbase main.c -mtune=generic -march=x86-64 -auxbase-strip main.o -version -o /tmp/cc4SIMck.s
GNU C11 (GCC) version 7.5.0 (x86_64-pc-linux-gnu)
    compiled by GNU C version 7.5.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version none
warning: GMP header version 6.3.0 differs from library version 6.2.1.
warning: MPFR header version 4.2.1 differs from library version 4.1.0.
warning: MPC header version 1.3.1 differs from library version 1.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/include
 /usr/local/include
 /home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/include
 /home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C11 (GCC) version 7.5.0 (x86_64-pc-linux-gnu)
    compiled by GNU C version 7.5.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version none
warning: GMP header version 6.3.0 differs from library version 6.2.1.
warning: MPFR header version 4.2.1 differs from library version 4.1.0.
warning: MPC header version 1.3.1 differs from library version 1.2.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dcdda7853040608b660057cc697f1eb8
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'main.o' '-mtune=generic' '-march=x86-64'
 as -v --64 -o main.o /tmp/cc4SIMck.s
GNU assembler version 2.38 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.38
COMPILER_PATH=/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/libexec/gcc/x86_64-pc-linux-gnu/7.5.0/:/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/libexec/gcc/x86_64-pc-linux-gnu/7.5.0/:/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/libexec/gcc/x86_64-pc-linux-gnu/:/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/:/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/:/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/jizimo/relocation-type-from-got-to-plt/bin/gcc-7.5.0/lib/gcc/x86_64-pc-linux-gnu/7.5.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'main.o' '-mtune=generic' '-march=x86-64'
$> uname -a
Linux solegpu2 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật