This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: linking question


Hi Will

Will Wagner wrote:

> I'm interested in changing how my app links so that all the ecos
> functions come before my app functions. I assume to do this I need to
> shift my app code into different sections ie .text.app and
> .gnu.linkonce.app and then change the linker script file.
> 
> Would that work?

It would probably be easier to distinguish your application code using
object code filenames or by placing it all in an archive file with a
specific name. Take a look at the LD documentation on input sections:

http://sourceware.org/binutils/docs-2.19/ld/Input-Section-Basics.html

> My next question is how to specify that I want my code in a different
> section. I know how to do it by adding declarations to the source code
> but would like to not have to do that. Is there an easy way of changing
> the sections for a file or archive?

Fairly easy, but you will need to edit the linker script. Normally the
SECTION_text() macro in the eCos architecture-specific linker script
(*.ld) will gather the .text sections of _all_ object code files as follows:

  *(.text*)

But you can exclude the .text sections of a specific set of files as
follows:

  *(EXCLUDE_FILE (mycode1.o mycode2.o) .text*)

and it would appear that you can exclude the .text sections from an
entire archive using something like:

  *(EXCLUDE_FILE (mycode.a:) .text*)

You can then gather the .text sections of the excluded objects into a
new section using a new macro such as SECTION_mytext().

Finally, you will need to reference the new SECTION_mytext() macro
within the relevant .ldi files in your eCos platform HAL package.

John Dallaway

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]