public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Linker question
@ 2008-10-02  9:00 palparni
  2008-10-02 12:56 ` Ramana Radhakrishnan
  2008-10-02 15:30 ` Nick Clifton
  0 siblings, 2 replies; 7+ messages in thread
From: palparni @ 2008-10-02  9:00 UTC (permalink / raw)
  To: binutils


Hi,

I'm not sure if this info is already present on the mailing list.
I'd like to know if it is possible to determine at the linking phase whether
a function has been referred to through function pointer.
If it is, could you give me some ideas on how to do this. I'd need to use
this in the emulation file of a microcontroller.

Thanks,
Alpar
-- 
View this message in context: http://www.nabble.com/Linker-question-tp19775703p19775703.html
Sent from the Sourceware - binutils list mailing list archive at Nabble.com.

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

* Re: Linker question
  2008-10-02  9:00 Linker question palparni
@ 2008-10-02 12:56 ` Ramana Radhakrishnan
  2008-10-03  6:55   ` palparni
  2008-10-02 15:30 ` Nick Clifton
  1 sibling, 1 reply; 7+ messages in thread
From: Ramana Radhakrishnan @ 2008-10-02 12:56 UTC (permalink / raw)
  To: palparni; +Cc: binutils

On Thu, Oct 2, 2008 at 9:59 AM, palparni <palparni@gmail.com> wrote:
>
> Hi,
>
> I'm not sure if this info is already present on the mailing list.
> I'd like to know if it is possible to determine at the linking phase whether
> a function has been referred to through function pointer.
> If it is, could you give me some ideas on how to do this. I'd need to use
> this in the emulation file of a microcontroller.

Well , the information is present in the ELF symtab if you are using
ELF as your object file format

The assignment to the function pointer of a function will create a
data relocation for the function at either the data section where the
initialization happens or in the code section if the function pointer
is set up in a function inside code. So all you do when you do the
final relocs is to see if the DEF of this symbol refers to a function
or an object. The information whether the symbol is a function or an
object is IIRC in the symbol type in the elf symbol table.


cheers
Ramana




> Thanks,
> Alpar
> --
> View this message in context: http://www.nabble.com/Linker-question-tp19775703p19775703.html
> Sent from the Sourceware - binutils list mailing list archive at Nabble.com.
>
>



-- 
Ramana Radhakrishnan

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

* Re: Linker question
  2008-10-02  9:00 Linker question palparni
  2008-10-02 12:56 ` Ramana Radhakrishnan
@ 2008-10-02 15:30 ` Nick Clifton
  1 sibling, 0 replies; 7+ messages in thread
From: Nick Clifton @ 2008-10-02 15:30 UTC (permalink / raw)
  To: palparni; +Cc: binutils

Hi Alpar,

> I'm not sure if this info is already present on the mailing list.
> I'd like to know if it is possible to determine at the linking phase whether
> a function has been referred to through function pointer.

Yes and no.  As Ramana has mentioned it is possible to tell whether a 
function is referenced from somewhere else in the code by looking at the 
relocations in the object files.  It is not always possible to tell 
whether this is a function call or an assignment to a function pointer 
however.  (It depends upon the target as to whether this distinction can 
be made).

Also the linker cannot determine run-time control flow behaviour, so it 
is possible that the address of a function is taken in a piece of code 
that is never executed, making it appear that the function is referenced 
when in fact it never is.

Cheers
   Nick


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

* Re: Linker question
  2008-10-02 12:56 ` Ramana Radhakrishnan
@ 2008-10-03  6:55   ` palparni
  0 siblings, 0 replies; 7+ messages in thread
From: palparni @ 2008-10-03  6:55 UTC (permalink / raw)
  To: binutils


Hi,

Thanks for your help, it was useful. I'll see what I can do based on your
answers.

Regards,
Alpar


Ramana Radhakrishnan wrote:
> 
> On Thu, Oct 2, 2008 at 9:59 AM, palparni <palparni@gmail.com> wrote:
>>
>> Hi,
>>
>> I'm not sure if this info is already present on the mailing list.
>> I'd like to know if it is possible to determine at the linking phase
>> whether
>> a function has been referred to through function pointer.
>> If it is, could you give me some ideas on how to do this. I'd need to use
>> this in the emulation file of a microcontroller.
> 
> Well , the information is present in the ELF symtab if you are using
> ELF as your object file format
> 
> The assignment to the function pointer of a function will create a
> data relocation for the function at either the data section where the
> initialization happens or in the code section if the function pointer
> is set up in a function inside code. So all you do when you do the
> final relocs is to see if the DEF of this symbol refers to a function
> or an object. The information whether the symbol is a function or an
> object is IIRC in the symbol type in the elf symbol table.
> 
> 
> cheers
> Ramana
> 
> 
> 
> 
>> Thanks,
>> Alpar
>> --
>> View this message in context:
>> http://www.nabble.com/Linker-question-tp19775703p19775703.html
>> Sent from the Sourceware - binutils list mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Ramana Radhakrishnan
> 
> 

-- 
View this message in context: http://www.nabble.com/Linker-question-tp19775703p19792989.html
Sent from the Sourceware - binutils list mailing list archive at Nabble.com.

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

* Linker question
@ 2005-07-22 13:27 Michael Trimarchi
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Trimarchi @ 2005-07-22 13:27 UTC (permalink / raw)
  To: binutils

Hi all,
I have a software project. The first one is compiled with the arm 2.95.2 
arm cross toolchain and the second one is width the arm 3.3.3 . I have a 
lot of char array and each one in different object file. If I compile 
and link width the first toolchain the char arrays are 4 byte aligh 
maybe because they are in different object file but if I compile and 
link width the second one I have a lot of these not align at 4byte. I 
fix this behavior with the align directive at source code level and I 
build another toolchain forcing the data align at 32 bit. The ld version 
is 2.15 for the gcc 3.3.3 .... Any of us know what is changed?

Regards Michael


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

* Re: Linker question
  2003-06-13 15:38 Sumesh UdayaKumaran
@ 2003-06-17  8:22 ` Nick Clifton
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Clifton @ 2003-06-17  8:22 UTC (permalink / raw)
  To: sumesh_uk; +Cc: binutils

Hi Sumesh,

>    As part of a project Iam involved in, I need to maintain copies
> of the same variable in different memory banks (kind of like
> cache). I then want to based on criteria I have address the
> different copies at different program points.

This sounds like a very strange scheme.  How do you intend to keep the
variables in sync ?  ie if a program changes variable A in bank1, how
do make sure that the copy of variable A in bank2 also changes ?

> 1. Where is the exact address being generated.

For most cases the addresses are generated in the linker.  Depending
upon the target processor's instruction set and the form of addressing
being used the addresses can also sometimes be computed in the
assembler or in the loader.

In your situation however, the most likely place where the addresses
are computed is the function "mcore_elf_relocate_section" which is
defined in bfd/elf32-mcore.c


> 2. As an alternative , can I handle such a scheme through a script, in
> other words can the script be used to guide such an addressing.

You might be able to do something clever using linker scripts and
overlays although I do not think that they are really designed to
handle this kind of thing.

I would suggest however that you consider very carefully if you really
want multiple copies of the same variable at different addresses,
since this is not something that the assembler or linker are really
designed to allow.

Cheers
        Nick
        

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

* Linker question
@ 2003-06-13 15:38 Sumesh UdayaKumaran
  2003-06-17  8:22 ` Nick Clifton
  0 siblings, 1 reply; 7+ messages in thread
From: Sumesh UdayaKumaran @ 2003-06-13 15:38 UTC (permalink / raw)
  To: binutils

Hi
   As part of a project Iam involved in, I need to maintain copies of the 
same variable in different memory banks (kind of like cache). I then want to 
based on criteria I have address the different copies at different program 
points.

             Eg            ldw r3,A ....................Address the copy of 
global variable A in bank1.

                             ..................

                            ................
                           ldw r4, A            Address the copy of global 
variable A in bank2



Iam implementing this on a gcc cross compiler for mcore-elf.

From what I have figured so far (Iam really new to this whole world of 
linking and assembling ), I can handle this at the stage when the exact 
addresses are being generated.

The questions I had were:
1. Where is the exact address being generated.
2. As an alternative , can I handle such a scheme through a script, in other 
words can the script be used to guide such an addressing.


Any pointers, suggestions will be great


thanks
sumesh

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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

end of thread, other threads:[~2008-10-03  6:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-02  9:00 Linker question palparni
2008-10-02 12:56 ` Ramana Radhakrishnan
2008-10-03  6:55   ` palparni
2008-10-02 15:30 ` Nick Clifton
  -- strict thread matches above, loose matches on Subject: below --
2005-07-22 13:27 Michael Trimarchi
2003-06-13 15:38 Sumesh UdayaKumaran
2003-06-17  8:22 ` Nick Clifton

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