Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
817 Views

Custom Linker Script

Dear all, 

I have to add an output section in the final binary called "EXTSec". Therefore, I modified the makefile to point to a linkerscript.lds. Then I copied the original likerscript.x contents, which is located in ./bsp folder, and pasted it into my linkerscript.lds. After that, I added the following output section 

 

.EXTsec : 

./obj/CRT1.o 

 

} > SDRAM 

 

As a result, I got the following error 

./obj/CRT1.o: In function `Task_CRT1': 

multiple definition of `Task_CRT1' 

obj/CRT1.o CRT1.c:19: first defined here 

collect2: ld returned 1 exit status 

make: ***[App.elf] Error 1 

 

I need to put all input sections in that object file at the same output section contiguously.
0 Kudos
12 Replies
Altera_Forum
Honored Contributor I
53 Views

Have any one worked with linker script for NIOS II?

Altera_Forum
Honored Contributor I
53 Views

At a guess you've requested a single .o file be placed into two separate sections - so all its symbols are replicated.

Altera_Forum
Honored Contributor I
53 Views

According to GCC documentation all explicit assignment overwrite implicit assignment. 

 

I really need to resolve this issue. I need to dump all input sections in that file into one output section, and I don't care about the rest files.
Altera_Forum
Honored Contributor I
53 Views

I need to understand, what sections have different VMA and LMA and why. How the start-up code loads stuff to VMA. 

 

I program my FPGA using NIOS II SBTE (software building tools for eclipse). Is this means that it will program it right into RAM (VMA) without loading any thing from Flash memory? 

 

Any info in this matter will be appreciated.
Altera_Forum
Honored Contributor I
53 Views

:o 

I solved the problem by providing exactly the same path to the file that is used by the makefile to invoke the linker. It appeared that any modification in the path the linker considers it as a new object file. Thus, multiple definitions, of the global symbols in that file, error occurred in my case.
Altera_Forum
Honored Contributor I
53 Views

Hi,  

 

I face the same problem. My linker script is as follows 

 

--- Quote Start ---  

 

SECTIONS 

.pcode ALIGN(0x1000) : {  

__pcode_start = .; 

*(.pcode) 

. = ALIGN(0x1000); 

__pcode_end = .;  

.tcode ALIGN(0x1000) : {  

__tcode_start = .; 

*(.tcode) 

. = ALIGN(0x1000); 

__tcode_end = .;  

 

--- Quote End ---  

 

 

and I get the following error messages: 

 

 

--- Quote Start ---  

/usr/src/linux-3.9.4/sound/usb/****/utils.o: In function `__pcode_start': 

(.pcode+0x0): multiple definition of `__pcode_start' 

/usr/src/linux-3.9.4/sound/usb/****/vmm.o : (.pcode+0x0): first defined here 

/usr/src/linux-3.9.4/sound/usb/****/utils.o: In function `__tcode_end': 

(.tcode+0x0): multiple definition of `__tcode_end' 

/usr/src/linux-3.9.4/sound/usb/****/vmm.o : (.tcode+0x0): first defined here 

/usr/src/linux-3.9.4/sound/usb/****/utils.o: In function `__tcode_end': 

(.tcode+0x0): multiple definition of `__tcode_start' 

/usr/src/linux-3.9.4/sound/usb/****/vmm.o: (.tcode+0x0): first defined here 

/usr/src/linux-3.9.4/sound/usb/****/utils.o: In function `__pcode_start': 

(.pcode+0x0): multiple definition of `__pcode_end' 

/usr/src/linux-3.9.4/sound/usb/****/vmm.o: (.pcode+0x0): first defined here 

make[1]: *** [/usr/src/linux-3.9.4/sound/usb/snd-usb-audio.o] Error 1 

 

--- Quote End ---  

 

 

I didn't get the solution you mentioned.  

 

--- Quote Start ---  

:o 

I solved the problem by providing exactly the same path to the file that is used by the makefile to invoke the linker. It appeared that any modification in the path the linker considers it as a new object file. Thus, multiple definitions, of the global symbols in that file, error occurred in my case. 

--- Quote End ---  

 

 

Can you please give me some clue?
Altera_Forum
Honored Contributor I
53 Views

You have to make sure that the linker will not read the content of the same object file twice. For example, you cannot direct the linker through the linker script to put some content of an object file in certain addresses while that object file is part of a library that is passed to the linker.

Altera_Forum
Honored Contributor I
53 Views

Thanks for your reply. I assume something like duplication is happening. I'll describe my sitution, please help me with your any comments/suggestions. 

 

I want to implement a function named 'validate()' in sound/usb driver and make it accessible to drivers/usb/host/xhci_hcd driver. For that, I declare validate() as an extern function in /include/linux/usb/hcd.h, which is included by both the relevant files in sound and xhci drivers. Then I do export_symbol(validate) from sound driver and use KBUILD_EXTRA_SYMBOLS=/usr/src/linux-3.9.4/sound/usb/Module.symvers in the Makefile of xhci_hcd driver.  

 

Simultaneously, I am using the above mentioned linker script in the makefile of sound driver. Whenever I do the export_symbol(validate), building the sound driver gives me above erros. Can you please explain me what's happening here, whether xhci_driver is duplicating snd-usb-audio.o? How can I resolve the error and accomplish what I want to do?
Altera_Forum
Honored Contributor I
53 Views

Thanks for your reply. I assume something like duplication is happening. I'll describe my sitution, please help me with your any comments/suggestions. 

 

I want to implement a function named 'validate()' in sound/usb driver and make it accessible to drivers/usb/host/xhci_hcd driver. For that, I declare validate() as an extern function in /include/linux/usb/hcd.h, which is included by both the relevant files in sound and xhci drivers. Then I do export_symbol(validate) from sound driver and use KBUILD_EXTRA_SYMBOLS=/usr/src/linux-3.9.4/sound/usb/Module.symvers in the Makefile of xhci_hcd driver.  

 

Simultaneously, I am using the above mentioned linker script in the makefile of sound driver. Whenever I do the export_symbol(validate), building the sound driver gives me above erros. Can you please explain me what's happening here, whether xhci_driver is duplicating snd-usb-audio.o? How can I resolve the error and accomplish what I want to do?
Altera_Forum
Honored Contributor I
53 Views

I suggest you to do it in two steps. First compile all .c files into .o files then invoke the linker and pass the linker script as an argument. What I'm suspecting is that the makefile is passing some arguments to the linker that you are not aware of.  

 

One question for you, where do you tag your code with .pcode and .tcode sections? this can explain the strange behaviour of the linker
Altera_Forum
Honored Contributor I
53 Views

I'd check the symbol tables of the vmm.o and utils.o - I think you'll find that they both have definitions for the symbols (possibly where they are used).

Altera_Forum
Honored Contributor I
53 Views

 

--- Quote Start ---  

You have to make sure that the linker will not read the content of the same object file twice. For example, you cannot direct the linker through the linker script to put some content of an object file in certain addresses while that object file is part of a library that is passed to the linker. 

--- Quote End ---  

 

 

Can you please inform me how to do this? Using eclipse here and I'm at my witts end with it!! Same error and feel like I've tried everything! Thanks
Reply