public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem with linking static lib text into specific section
@ 2012-03-04 20:52 Elad Yosef
  2012-03-05  5:02 ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-03-04 20:52 UTC (permalink / raw)
  To: gcc-help

Hi I have the following in my linker script:

I'm forcing to link the text and the rodata from libMy-Cli.a into a
specific section.
Now I have additional file libMy-GUI.a that I also want to link in similar way.
But It fails I get linking error that some addresses are out of the memory.
Is there more elegant way to what i'm trying to achieve?



#define SECTION_text(_region_, _vma_, _lma_)   \
  .text _vma_ : _lma_                          \
    {                                                \
      _stext = .; _ftext = . ;                 \
      *(EXCLUDE_FILE (*libMy-Cli.a) .text)   \
      *(EXCLUDE_FILE (*libMy-Cli.a) .text.*) \
      *(.stub)                                     \
      *(.gnu.warning)                          \
      *(.gnu.linkonce.t*)                      \
      *(.mips16.fn.*) *(.mips16.call.*)   \
    } > _region_ =0                            \
  _etext = .; PROVIDE (etext = .);

#define SECTION_rodata(_region_, _vma_, _lma_)        \
  .rodata _vma_ : _lma_                               \
    {                                                             \
      FORCE_OUTPUT;                                 \
      *(EXCLUDE_FILE (*libMy-Cli.a) .rodata)   \
      *(EXCLUDE_FILE (*libMy-Cli.a) .rodata.*) \
      *(.gnu.linkonce.r*)                                    \
    } > _region_

#define SECTION_statLib_text(_region_, _vma_, _lma_)     \
	.statLib_text _vma_ : _lma_               	  	    \
    {                                                           \
    	FORCE_OUTPUT;                             \
    	KEEP(*( SORT (.my.cli.table.*)));		\
    	libMy-Cli.a (.text)                	        \
      	libMy-Cli.a *(.text.*)              	        \
      	libMy-Cli.a (.rodata)              	        \
        libMy-Cli.a *(.rodata.*)				\
    } > _region_ 	


Thanks

Elad

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

* Re: Problem with linking static lib text into specific section
  2012-03-04 20:52 Problem with linking static lib text into specific section Elad Yosef
@ 2012-03-05  5:02 ` Ian Lance Taylor
  2012-03-05 18:02   ` Elad Yosef
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Lance Taylor @ 2012-03-05  5:02 UTC (permalink / raw)
  To: Elad Yosef; +Cc: gcc-help

Elad Yosef <elad.yosef@gmail.com> writes:

> Hi I have the following in my linker script:
>
> I'm forcing to link the text and the rodata from libMy-Cli.a into a
> specific section.
> Now I have additional file libMy-GUI.a that I also want to link in similar way.
> But It fails I get linking error that some addresses are out of the memory.
> Is there more elegant way to what i'm trying to achieve?

What is the exact error message?

This general approach should work.

Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-05  5:02 ` Ian Lance Taylor
@ 2012-03-05 18:02   ` Elad Yosef
  2012-03-05 19:58     ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-03-05 18:02 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

When I add the new lib the ld file has these changes


#define SECTION_text(_region_, _vma_, _lma_)   \
  .text _vma_ : _lma_                          \
    {                                          \
      _stext = .; _ftext = . ;                 \
     *(EXCLUDE_FILE (*libMy-Cli.a) .text)    \
     *(EXCLUDE_FILE (*libMy-Cli.a) .text.*)  \
     *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .text)    \     --- New LIB
     *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .text.*)  \     --- New LIB
      *(.stub)                                 \
      *(.gnu.warning)                          \
      *(.gnu.linkonce.t*)                      \
      *(.mips16.fn.*) *(.mips16.call.*)        \
    } > _region_ =0                            \
  _etext = .; PROVIDE (etext = .);

#define SECTION_rodata(_region_, _vma_, _lma_)      \
  .rodata _vma_ : _lma_                             \
    {                                               \
      FORCE_OUTPUT; 								\
     *(EXCLUDE_FILE (*libMy-Cli.a) .rodata)   	\
     *(EXCLUDE_FILE (*libMy-Cli.a) .rodata.*) 	\
     *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .rodata)   	\ --- New LIB
     *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .rodata.*) 	\ --- New LIB
      *(.gnu.linkonce.r*)    						\
    } > _region_

/* those linker changes are for Flash section */
#define SECTION_statLib_text(_region_, _vma_, _lma_)    \
	.statLib_text _vma_ : _lma_               	  	    \
    {                                                   \
    	FORCE_OUTPUT;									\
    	KEEP(*( SORT (.ecos.cli.table.*)));				\
        libMy-Cli.a (.text)                           \
        libMy-Cli.a *(.text.*)                        \
        libMy-Cli.a (.rodata)                         \
        libMy-Cli.a *(.rodata.*)                      \
        libMy-ATP-GUI.a (.text)                           \   --- New LIB
        libMy-ATP-GUI.a *(.text.*)                        \   --- New LIB
        libMy-ATP-GUI.a (.rodata)                         \  --- New LIB
        libMy-ATP-GUI.a *(.rodata.*)                      \  --- New LIB
    } > _region_


I get the following error::::
/localhome/eCos/gnutools/mipsisa32-elf/bin/../lib/gcc/mipsisa32-elf/4.3.2/../../../../mipsisa32-elf/bin/ld:
address 0x80058264 of mars section .bss is not within region ram
/localhome/eCos/gnutools/mipsisa32-elf/bin/../lib/gcc/mipsisa32-elf/4.3.2/../../../../mipsisa32-elf/bin/ld:
address 0x80058264 of mars section .bss is not within region ram
collect2: ld returned 1 exit status
make: *** [mars] Error 1

**** NOTE ****
When I increase the size of the "ram" region it all goes well.
It Looks like that when I add the new Lib in the ld file it totally
ignores the sections of the both libs
and links them into the ram region and not into the specified section
that i have defined.
The only output that I see in my section is from
KEEP(*( SORT (.ecos.cli.table.*)));

command


Thanks

Elad



On Mon, Mar 5, 2012 at 7:01 AM, Ian Lance Taylor <iant@google.com> wrote:
>
> Elad Yosef <elad.yosef@gmail.com> writes:
>
> > Hi I have the following in my linker script:
> >
> > I'm forcing to link the text and the rodata from libMy-Cli.a into a
> > specific section.
> > Now I have additional file libMy-GUI.a that I also want to link in similar way.
> > But It fails I get linking error that some addresses are out of the memory.
> > Is there more elegant way to what i'm trying to achieve?
>
> What is the exact error message?
>
> This general approach should work.
>
> Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-05 18:02   ` Elad Yosef
@ 2012-03-05 19:58     ` Ian Lance Taylor
  2012-03-05 21:54       ` Elad Yosef
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Lance Taylor @ 2012-03-05 19:58 UTC (permalink / raw)
  To: Elad Yosef; +Cc: gcc-help

Elad Yosef <elad.yosef@gmail.com> writes:

> When I add the new lib the ld file has these changes
>
>
> #define SECTION_text(_region_, _vma_, _lma_)   \
>   .text _vma_ : _lma_                          \
>     {                                          \
>       _stext = .; _ftext = . ;                 \
>      *(EXCLUDE_FILE (*libMy-Cli.a) .text)    \
>      *(EXCLUDE_FILE (*libMy-Cli.a) .text.*)  \
>      *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .text)    \     --- New LIB
>      *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .text.*)  \     --- New LIB

I don't see how that could work.  The first EXCLUDE_FILE will match the
second library, and the second EXCLUDE_FILE will match the first
library.  I think you need to write something like

  *(EXCLUDE_FILE (*libMy-Cli.a *libMy-ATP-GUI.a) .text .text.*)

Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-05 19:58     ` Ian Lance Taylor
@ 2012-03-05 21:54       ` Elad Yosef
  2012-03-05 22:17         ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-03-05 21:54 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Hi,
I have tried changing the exclude rule as suggested but still the same error.
Does my new section rules are O.K?

Thanks

Elad



On Mon, Mar 5, 2012 at 9:57 PM, Ian Lance Taylor <iant@google.com> wrote:
> Elad Yosef <elad.yosef@gmail.com> writes:
>
>> When I add the new lib the ld file has these changes
>>
>>
>> #define SECTION_text(_region_, _vma_, _lma_)   \
>>   .text _vma_ : _lma_                          \
>>     {                                          \
>>       _stext = .; _ftext = . ;                 \
>>      *(EXCLUDE_FILE (*libMy-Cli.a) .text)    \
>>      *(EXCLUDE_FILE (*libMy-Cli.a) .text.*)  \
>>      *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .text)    \     --- New LIB
>>      *(EXCLUDE_FILE (*libMy-ATP-GUI.a) .text.*)  \     --- New LIB
>
> I don't see how that could work.  The first EXCLUDE_FILE will match the
> second library, and the second EXCLUDE_FILE will match the first
> library.  I think you need to write something like
>
>  *(EXCLUDE_FILE (*libMy-Cli.a *libMy-ATP-GUI.a) .text .text.*)
>
> Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-05 21:54       ` Elad Yosef
@ 2012-03-05 22:17         ` Ian Lance Taylor
  2012-03-06  5:44           ` Elad Yosef
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Lance Taylor @ 2012-03-05 22:17 UTC (permalink / raw)
  To: Elad Yosef; +Cc: gcc-help

Elad Yosef <elad.yosef@gmail.com> writes:

> I have tried changing the exclude rule as suggested but still the same error.
> Does my new section rules are O.K?

Time to use the -M option to generate a map file to confirm that the
data is going where you want it to.

If your data is going where you want, and your memory region is
overflowing, then you need to make your region larger or make your code
smaller.

Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-05 22:17         ` Ian Lance Taylor
@ 2012-03-06  5:44           ` Elad Yosef
  2012-03-06  9:37             ` Elad Yosef
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-03-06  5:44 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Hi,
I checked that by increasing the ram region size and found that both
libs text and rodata is linked in the wrong place.
It is linked into the ram region and not into my section.

Thanks

Elad

On Tue, Mar 6, 2012 at 12:17 AM, Ian Lance Taylor <iant@google.com> wrote:
> Elad Yosef <elad.yosef@gmail.com> writes:
>
>> I have tried changing the exclude rule as suggested but still the same error.
>> Does my new section rules are O.K?
>
> Time to use the -M option to generate a map file to confirm that the
> data is going where you want it to.
>
> If your data is going where you want, and your memory region is
> overflowing, then you need to make your region larger or make your code
> smaller.
>
> Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-06  5:44           ` Elad Yosef
@ 2012-03-06  9:37             ` Elad Yosef
  2012-05-29  9:40               ` Elad Yosef
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-03-06  9:37 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Hi,
Don't ask me how but somehow it works now

The original ld file with your fix

Thank you very much

Elad

On Tue, Mar 6, 2012 at 7:43 AM, Elad Yosef <elad.yosef@gmail.com> wrote:
> Hi,
> I checked that by increasing the ram region size and found that both
> libs text and rodata is linked in the wrong place.
> It is linked into the ram region and not into my section.
>
> Thanks
>
> Elad
>
> On Tue, Mar 6, 2012 at 12:17 AM, Ian Lance Taylor <iant@google.com> wrote:
>> Elad Yosef <elad.yosef@gmail.com> writes:
>>
>>> I have tried changing the exclude rule as suggested but still the same error.
>>> Does my new section rules are O.K?
>>
>> Time to use the -M option to generate a map file to confirm that the
>> data is going where you want it to.
>>
>> If your data is going where you want, and your memory region is
>> overflowing, then you need to make your region larger or make your code
>> smaller.
>>
>> Ian

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

* Re: Problem with linking static lib text into specific section
  2012-03-06  9:37             ` Elad Yosef
@ 2012-05-29  9:40               ` Elad Yosef
  2012-05-29 17:49                 ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-05-29  9:40 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Hi,
I have the following linker script

/* those linker changes are for Flash section */
#define SECTION_cliLib_tree(_region_, _vma_, _lma_)    \
	.cliLib_tree _vma_ : _lma_               	  	    \
    {                                                   \
    	FORCE_OUTPUT;\
    	KEEP(*( SORT (.ecos.cli.table.*)));				\
    }> _region_ 	

#define SECTION_cliLib_text(_region_, _vma_, _lma_)    \
	.cliLib_text _vma_ : _lma_               	  	    \
    {                                                   \
    	FORCE_OUTPUT;\
    	libMars-Cli.a (.text)                	        \
      	libMars-Cli.a *(.text.*)              	        \
      	libMars-Cli.a (.rodata)              	        \
        libMars-Cli.a *(.rodata.*)						\
    }> _region_ 	

#define SECTION_guiLib_text(_region_, _vma_, _lma_)    \
	.guiLib_text _vma_ : _lma_               	  	    \
    {                                                   \
    	FORCE_OUTPUT;\
    	KEEP(*( SORT (mars.syslog.table.*)));	\
        libMars-ATP-GUI.a (.text)                	        \
      	libMars-ATP-GUI.a *(.text.*)              	        \
      	libMars-ATP-GUI.a (.rodata)              	        \
        libMars-ATP-GUI.a *(.rodata.*)						\
    }> _region_ 	



SECTION_cliLib_tree - is fine and has the data in want.
SECTION_cliLib_text - is bad is also has the text & rodata that I want
to be in SECTION_guiLib_text.
SECTION_guiLib_text - is bad it has only the syslog table from KEEP(*(
SORT (mars.syslog.table.*)));

Please help
Elad











On Tue, Mar 6, 2012 at 12:36 PM, Elad Yosef <elad.yosef@gmail.com> wrote:
> Hi,
> Don't ask me how but somehow it works now
>
> The original ld file with your fix
>
> Thank you very much
>
> Elad
>
> On Tue, Mar 6, 2012 at 7:43 AM, Elad Yosef <elad.yosef@gmail.com> wrote:
>> Hi,
>> I checked that by increasing the ram region size and found that both
>> libs text and rodata is linked in the wrong place.
>> It is linked into the ram region and not into my section.
>>
>> Thanks
>>
>> Elad
>>
>> On Tue, Mar 6, 2012 at 12:17 AM, Ian Lance Taylor <iant@google.com> wrote:
>>> Elad Yosef <elad.yosef@gmail.com> writes:
>>>
>>>> I have tried changing the exclude rule as suggested but still the same error.
>>>> Does my new section rules are O.K?
>>>
>>> Time to use the -M option to generate a map file to confirm that the
>>> data is going where you want it to.
>>>
>>> If your data is going where you want, and your memory region is
>>> overflowing, then you need to make your region larger or make your code
>>> smaller.
>>>
>>> Ian

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

* Re: Problem with linking static lib text into specific section
  2012-05-29  9:40               ` Elad Yosef
@ 2012-05-29 17:49                 ` Ian Lance Taylor
  2012-05-29 18:21                   ` Elad Yosef
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Lance Taylor @ 2012-05-29 17:49 UTC (permalink / raw)
  To: Elad Yosef; +Cc: gcc-help

Elad Yosef <elad.yosef@gmail.com> writes:

>       	libMars-Cli.a *(.text.*)              	        \

This is a list of file names.  It will match any file name that matches
libMars-Cli.a or *.  In other words, since * matches every file name,
this will match every file name.

To match a file within an archive, write archive-name:file-name.  To
match the whole archive, write archive-name:.  See
http://sourceware.org/binutils/docs-2.22/ld/Input-Section-Basics.html .

Ian

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

* Re: Problem with linking static lib text into specific section
  2012-05-29 17:49                 ` Ian Lance Taylor
@ 2012-05-29 18:21                   ` Elad Yosef
  2012-05-29 19:46                     ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Elad Yosef @ 2012-05-29 18:21 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Doesn't it match only the files names from the specified archive?

On Tue, May 29, 2012 at 8:48 PM, Ian Lance Taylor <iant@google.com> wrote:
> Elad Yosef <elad.yosef@gmail.com> writes:
>
>>               libMars-Cli.a *(.text.*)                        \
>
> This is a list of file names.  It will match any file name that matches
> libMars-Cli.a or *.  In other words, since * matches every file name,
> this will match every file name.
>
> To match a file within an archive, write archive-name:file-name.  To
> match the whole archive, write archive-name:.  See
> http://sourceware.org/binutils/docs-2.22/ld/Input-Section-Basics.html .
>
> Ian

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

* Re: Problem with linking static lib text into specific section
  2012-05-29 18:21                   ` Elad Yosef
@ 2012-05-29 19:46                     ` Ian Lance Taylor
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Lance Taylor @ 2012-05-29 19:46 UTC (permalink / raw)
  To: Elad Yosef; +Cc: gcc-help

Elad Yosef <elad.yosef@gmail.com> writes:

> Doesn't it match only the files names from the specified archive?

There is no colon there, so, no.  You can have a list of file name
patterns, and that is what is happening here.

Ian


> On Tue, May 29, 2012 at 8:48 PM, Ian Lance Taylor <iant@google.com> wrote:
>> Elad Yosef <elad.yosef@gmail.com> writes:
>>
>>>               libMars-Cli.a *(.text.*)                        \
>>
>> This is a list of file names.  It will match any file name that matches
>> libMars-Cli.a or *.  In other words, since * matches every file name,
>> this will match every file name.
>>
>> To match a file within an archive, write archive-name:file-name.  To
>> match the whole archive, write archive-name:.  See
>> http://sourceware.org/binutils/docs-2.22/ld/Input-Section-Basics.html .
>>
>> Ian

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

end of thread, other threads:[~2012-05-29 19:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-04 20:52 Problem with linking static lib text into specific section Elad Yosef
2012-03-05  5:02 ` Ian Lance Taylor
2012-03-05 18:02   ` Elad Yosef
2012-03-05 19:58     ` Ian Lance Taylor
2012-03-05 21:54       ` Elad Yosef
2012-03-05 22:17         ` Ian Lance Taylor
2012-03-06  5:44           ` Elad Yosef
2012-03-06  9:37             ` Elad Yosef
2012-05-29  9:40               ` Elad Yosef
2012-05-29 17:49                 ` Ian Lance Taylor
2012-05-29 18:21                   ` Elad Yosef
2012-05-29 19:46                     ` Ian Lance Taylor

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