public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* how to generate - "procedure linkage table" for MIPS
@ 2018-03-05  9:23 V R
  2018-04-05  0:05 ` Maciej W. Rozycki
  0 siblings, 1 reply; 2+ messages in thread
From: V R @ 2018-03-05  9:23 UTC (permalink / raw)
  To: gcc

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













#####################################################################################

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how to generate - "procedure linkage table" for MIPS
  2018-03-05  9:23 how to generate - "procedure linkage table" for MIPS V R
@ 2018-04-05  0:05 ` Maciej W. Rozycki
  0 siblings, 0 replies; 2+ messages in thread
From: Maciej W. Rozycki @ 2018-04-05  0:05 UTC (permalink / raw)
  To: V R; +Cc: gcc

Hi Vidya,

On Mon, 5 Mar 2018, V R wrote:

> 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.

 What problem are you trying to solve?  Can you run `readelf -S' on a MIPS 
executable you think you have a trouble with and post the result?

 NB MIPS shared libraries use the so called lazy binding stubs, where the 
call is always indirect, rather than a procedure linkage table to achieve 
a similar effect, so you won't ever see a PLT in a MIPS shared library.

  Maciej

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-04 23:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05  9:23 how to generate - "procedure linkage table" for MIPS V R
2018-04-05  0:05 ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).