This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
how to generate - "procedure linkage table" for MIPS
- From: V R <mipsdev18 at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 5 Mar 2018 14:53:51 +0530
- Subject: how to generate - "procedure linkage table" for MIPS
- Authentication-results: sourceware.org; auth=none
Hi MIPS developers ;
This is regarding usage of "procedure linkage table" for MIPS. I have
trouble and generating the plt stubs for
shared library calls and the steps are given below.
I understand that gcc-4.4 ; binutils - 2.19; glibc-2.9 are prereqs and I
have all packages above this on MIPS cluster.
###############################details######################################################
*Create own shared library *
##########foo.h##############################################################
#ifndef foo_h__
#define foo_h__
extern void foo(void);
#endif // foo_h__
#########foo.c###############################################################
#include <stdio.h>
void foo(void)
{
puts("Hello, I'm a shared library");
}
##############create a shared
library########################################
gcc -fPIC -c foo.c
gcc -shared -fPIC -o libfoo.so foo.o ---------> shared library libfoo.
objdump -D libfoo.so | grep plt
Disassembly of section .rela.plt:
00000000000003c8 <.rela.plt>:
Disassembly of section .plt:
0000000000000410 <puts@plt-0x10>:
0000000000000420 <puts@plt>:
0000000000000430 <__cxa_finalize@plt>:
481: e8 aa ff ff ff callq 430 <__cxa_finalize@plt>
517: e8 04 ff ff ff callq 420 <puts@plt>
Disassembly of section .got.plt:
00000000002007a0 <.got.plt>:
###############################################################################
#################driver that calls my shared library function
foo()############
#include <stdio.h>
#include "foo.h"
int main(void)
{
puts("This is a shared library test...");
foo();
return 0;
}
#################compile
driver##################################################
gcc -o driver -L. -lfoo driver.c -------> driver code that calls foo().
###############disassemble
driver##############################################
objdump -D driver | grep plt
Disassembly of section .rela.plt:
0000000000400458 <.rela.plt>:
Disassembly of section .plt:
00000000004004b8 <puts@plt-0x10>:
00000000004004c8 <puts@plt>:
00000000004004d8 <__libc_start_main@plt>:
00000000004004e8 <foo@plt>:
400524: e8 af ff ff ff callq 4004d8 <__libc_start_main@plt
>
4005e1: e8 e2 fe ff ff callq 4004c8 <puts@plt>
4005e6: e8 fd fe ff ff callq 4004e8 <foo@plt>
Disassembly of section .got.plt:
#################################################################################
gcc options on x86 is :
gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib
--enable-__cxa_atexit --disable-libunwind-exceptions
--enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi
--disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)
The above said tasks works for x86 and similar exercise was carried out for
mips
architecture. It was found that even with -mplt option for gcc the plt
entries
were not found on disassembling the code.
Also on enabling gcc on MIPS with "–with-mips-plt " option the plt stub
wasnt seen. Is there
anything missing that needs to be done or is there any limitation , please
let me know.
-best regards
vidya
#####################################################################################