cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
arnobpau
Newbie
Newbie
252 Views
Registered: ‎03-24-2021

How to force symbols from a static library to be included in the compiled ELF file?

I am trying to include all the symbols (including unused symbols) from Microblaze static library into the compiled ELF file. I have tried using --whole-archive flag in MicroBlaze gcc compiler > Inferred Options > Software Platform > Software Platform Inferred Flags. But it failed compilation with this error:

 

mb-gcc: error: unrecognized command line option '--whole-archive'; did you mean '--whole-file'?

 

So, as suggested in the error message, I tried with--whole-file flag. It compiled but the unused symbols were not included in the compiled ELF file. Here is the main C file I want to compile: 

 

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "xil_exception.h"
#include "xstatus.h"
#include "xaxidma.h"
#include "xil_mem.h"
#include "util.h"
#include "xintc.h"
#include "constants.h"
#include "sleep.h"
#include "LedHeader.h"

const struct color RED =    {0x01ff, 0x0000, 0x0000};
const struct color YELLOW = {0x01ff, 0x01ff, 0x0000};
const struct color GREEN =  {0x0000, 0x01ff, 0x0000};
const struct color BLUE =   {0x0000, 0x0000, 0x01ff};

//int dummy ()
//{
//	usleep(500);
//}
int temp = 0xf1; /* attribute global variables*/

/*int _test()
{
    return main();
}*/
int fw_add () {
	return 5 + 3;
}
int main() /* NO main function should be there is SSC. Example : ssc_main */
{
    init_platform();
    u32 *led = (u32*) XPAR_RGB_PWM_0_PWM_AXI_BASEADDR;
    xil_printf("Setting LED color blue from SSC \n\r");
    setLED(led, BLUE);
    temp = temp  + 1;
    cleanup_platform();
    return fw_add() + temp;
}

 

Specifically, I want to add sleep, usleep, MB_Sleep symbols included in the ELF file. If I uncomment the dummy function in the above code, those symbols (i.e., sleep and others) get included, even without calling the function. But I want to include those symbols in the ELF file without using any dummy function. What can I do to solve this problem?

0 Kudos
0 Replies