public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: johnmc@sidsa.es
To: binutils@sources.redhat.com
Subject: Re: plt for arm gnu thumb
Date: Thu, 20 Apr 2006 14:32:00 -0000	[thread overview]
Message-ID: <1322.195.53.86.158.1145523785.squirrel@webmail> (raw)
In-Reply-To: <20060419150716.GA13655@nevyn.them.org>

> On Wed, Apr 19, 2006 at 05:00:15PM +0200, johnmc@sidsa.es wrote:
>> Hi Daniel
>
> Please, if you have further questions, send them to the list and not to
> me personally.  That's more useful for everyone.
>
> Also, if you want help, I recommend more precise reports: command lines
> used, test cases, objdump output for what appears to be wrong.
>
> --
> Daniel Jacobowitz
> CodeSourcery
>

hello

A couple of days ago I found out that the "procedure linkage table" - plt
produced  when transitioning
on an ARM V4t chip does not function.
So the suggestion was that I design my code so that the transition from
the plt is to an ARM compiled
function that then can call a THUMB compiled function.

I have been trying to do this and it does not seem to work either - or
maybe I am not doing it properly as
I have no previous experience using interworking.

In order to test this I have built a small test shared library .
Here are the commands I used to build this SHARED LIBRARY.

The 2 modules used are
dyn_load_module.c  - THUMB
dynamic_arm.c      - ARM


compile:
arm-elf-gcc -c -fpic  -mthumb -mthumb-interwork dyn_load_module.c  -o
dyn_load_module.o
arm-elf-gcc -c -fpic          -mthumb-interwork dynamic_arm.c      -o
dynamic_arm.o

shared link:
arm-elf-ld  -shared dyn_load_module.o   dynamic_arm.o   -o prog.out
=================================
here is the code:
dynamic_arm.c
void func_shared_arm(void)
{


   func_shared();


}


dyn_load_module.c
extern void func_shared(void);
static void func_shared_static(void);

int global_var = 0x3333;
int global_var1 = 0xaaaa;
int global_var2 = 0xbbbb;
int global_var3 = 0xeeee;
int global_var4 = 0xffff;
int global_var5 = 0xaaaa;
int global_var6 = 0xaaaa;
int global_var7 = 0xaaaa;
int global_var8 = 0xaaaa;
int global_var9 = 0xaaaa;

static int static_global_var = 0x4444;
static int static_global_var2 = 0x1111;

void func_shared(void)
{

   global_var = 0xff;
   static_global_var = 200;
   func_shared_static();


   int x =1;
}


static void func_shared_static(void)
{
   int x =1;
}
======================================





very simple stuff - ARM function func_shared_arm() - calls - THUMB funtion
func_shared()
but the assembler produced below just looks like RUBBISH!!

ANYONE GOT ANY IDEA WHAT I AM DOING WRONG -



dyn_load_module.s:     file format elf32-littlearm

SYMBOL TABLE:
00000094 l    d  .hash	00000000 .hash
00000150 l    d  .dynsym	00000000 .dynsym
00000310 l    d  .dynstr	00000000 .dynstr
00000410 l    d  .rel.dyn	00000000 .rel.dyn
00000420 l    d  .rel.plt	00000000 .rel.plt
00000428 l    d  .plt	00000000 .plt
00000448 l    d  .text	00000000 .text
000005c8 l    d  .dynamic	00000000 .dynamic
00000658 l    d  .got	00000000 .got
00000670 l    d  .data	00000000 .data
000006a0 l    d  .bss	00000000 .bss
00000000 l    d  .comment	00000000 .comment
00080000 l    d  .stack	00000000 .stack
00000000 l    d  *ABS*	00000000 .shstrtab
00000000 l    d  *ABS*	00000000 .symtab
00000000 l    d  *ABS*	00000000 .strtab
00000000 l    df *ABS*	00000000 dyn_load_module.c
00000698 l     O .data	00000004 static_global_var
0000069c l     O .data	00000004 static_global_var2
00000490 l     F .text	0000001c func_shared_static
00000000 l    df *ABS*	00000000 dynamic_arm.c
00000658 l     O *ABS*	00000000 .hidden _GLOBAL_OFFSET_TABLE_
00000670 g     O .data	00000004 global_var
000004c8 g       *ABS*	00000000 __exidx_end
000005c8 g     O *ABS*	00000000 _DYNAMIC
000006a0 g       *ABS*	00000000 _bss_end__
00000684 g     O .data	00000004 global_var5
000006a0 g       *ABS*	00000000 __bss_start__
000004c8 g       *ABS*	00000000 __exidx_start
0000068c g     O .data	00000004 global_var7
000006a0 g       *ABS*	00000000 __bss_end__
00000448 g     F .text	00000048 func_shared
00000694 g     O .data	00000004 global_var9
00000690 g     O .data	00000004 global_var8
000006a0 g       *ABS*	00000000 __bss_start
00000680 g     O .data	00000004 global_var4
000004ac g     F .text	0000001c func_shared_arm
000006a0 g       *ABS*	00000000 __end__
00000674 g     O .data	00000004 global_var1
00000678 g     O .data	00000004 global_var2
000006a0 g       *ABS*	00000000 _edata
000006a0 g       *ABS*	00000000 _end
00080000 g       .stack	00000000 _stack
00000670 g       .data	00000000 __data_start
00000688 g     O .data	00000004 global_var6
0000067c g     O .data	00000004 global_var3


Disassembly of section .plt:

00000428 <.plt>:
 428:	e52de004 	str	lr, [sp, #-4]!
 42c:	e59fe004 	ldr	lr, [pc, #4]	; 438 <func_shared-0x10>
 430:	e08fe00e 	add	lr, pc, lr
 434:	e5bef008 	ldr	pc, [lr, #8]!
 438:	00000220 	andeq	r0, r0, r0, lsr #4
 43c:	e28fc600 	add	ip, pc, #0	; 0x0
 440:	e28cca00 	add	ip, ip, #0	; 0x0
 444:	e5bcf220 	ldr	pc, [ip, #544]!
Disassembly of section .text:

00000448 <func_shared>:
 448:	b580      	push	{r7, lr}
 44a:	4657      	mov	r7, sl
 44c:	b480      	push	{r7}
 44e:	4f0d      	ldr	r7, [pc, #52]	(484 <.text+0x3c>)
 450:	46ba      	mov	sl, r7
 452:	44fa      	add	sl, pc
 454:	466f      	mov	r7, sp
 456:	b081      	sub	sp, #4
 458:	4b0b      	ldr	r3, [pc, #44]	(488 <.text+0x40>)
 45a:	4453      	add	r3, sl
 45c:	681a      	ldr	r2, [r3, #0]
 45e:	23ff      	mov	r3, #255
 460:	6013      	str	r3, [r2, #0]
 462:	4b0a      	ldr	r3, [pc, #40]	(48c <.text+0x44>)
 464:	4453      	add	r3, sl
 466:	681a      	ldr	r2, [r3, #0]
 468:	23c8      	mov	r3, #200
 46a:	6013      	str	r3, [r2, #0]
 46c:	f810f000 	bl	490 <func_shared_static>
 470:	1f3a      	sub	r2, r7, #4
 472:	2301      	mov	r3, #1
 474:	6013      	str	r3, [r2, #0]
 476:	46bd      	mov	sp, r7
 478:	bc04      	pop	{r2}
 47a:	4692      	mov	sl, r2
 47c:	bc80      	pop	{r7}
 47e:	bc01      	pop	{r0}
 480:	4700      	bx	r0
 482:	0000      	lsl	r0, r0, #0
 484:	0202      	lsl	r2, r0, #8
 486:	0000      	lsl	r0, r0, #0
 488:	0014      	lsl	r4, r2, #0
 48a:	0000      	lsl	r0, r0, #0
 48c:	0010      	lsl	r0, r2, #0
	...

00000490 <func_shared_static>:
 490:	b580      	push	{r7, lr}
 492:	4657      	mov	r7, sl
 494:	b480      	push	{r7}
 496:	466f      	mov	r7, sp
 498:	b081      	sub	sp, #4
 49a:	1f3a      	sub	r2, r7, #4
 49c:	2301      	mov	r3, #1
 49e:	6013      	str	r3, [r2, #0]
 4a0:	46bd      	mov	sp, r7
 4a2:	bc04      	pop	{r2}
 4a4:	4692      	mov	sl, r2
 4a6:	bc80      	pop	{r7}
 4a8:	bc01      	pop	{r0}
 4aa:	4700      	bx	r0

000004ac <func_shared_arm>:
 4ac:	e1a0c00d 	mov	ip, sp
 4b0:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
 4b4:	e24cb004 	sub	fp, ip, #4	; 0x4
 4b8:	ebffffdf 	bl	43c <func_shared-0xc>
 4bc:	e24bd00c 	sub	sp, fp, #12	; 0xc
 4c0:	e89d6800 	ldmia	sp, {fp, sp, lr}
 4c4:	e12fff1e 	bx	lr


  parent reply	other threads:[~2006-04-20  9:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-18 13:06 johnmc
2006-04-18 13:10 ` Daniel Jacobowitz
2006-04-18 15:14   ` johnmc
2006-04-18 15:45 ` Richard Earnshaw
2006-04-18 15:49   ` Daniel Jacobowitz
2006-04-18 16:01     ` Richard Earnshaw
2006-04-18 16:49       ` Daniel Jacobowitz
     [not found]         ` <4596.195.53.86.158.1145376723.squirrel@webmail>
     [not found]           ` <20060418203900.GA23304@nevyn.them.org>
     [not found]             ` <1178.195.53.86.158.1145458815.squirrel@webmail>
     [not found]               ` <20060419150716.GA13655@nevyn.them.org>
2006-04-20 14:32                 ` johnmc [this message]
2006-04-20 14:38                   ` Richard Earnshaw
     [not found]                     ` <1507.195.53.86.158.1145536917.squirrel@webmail>
     [not found]                       ` <1145538390.16122.39.camel@pc960.cambridge.arm.com>
     [not found]                         ` <1576.195.53.86.158.1145540607.squirrel@webmail>
     [not found]                           ` <1145541382.16122.62.camel@pc960.cambridge.arm.com>
2006-04-24 18:23                             ` johnmc
2006-04-25 17:19                               ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322.195.53.86.158.1145523785.squirrel@webmail \
    --to=johnmc@sidsa.es \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).