초보의 아웅다웅 설계하기/STM32

One Elf Section per Function 옵션???

로망와니 2018. 2. 8. 10:12

 

ST에서 Cypress에서처럼 emwin의 그래픽쪽 라이센스를 구매하였는지 예제 파일이 들어 있어서 카메라에서 이미지를 받아 그 이미지를 그래픽에 뿌려보려고 테스트를 하였습니다. 정상적으로 동작하지 않아 JPEG이미지를 가져와 코드에 넣고 확인하려했으나 이미지가 계속 나오지 않았습니다.

무엇때문일까? 왜 일까? 고심하다 one elf section per function 옵션을 제거해 보았습니다.

그랬더니 이미지가 똭!!!!!

그간 아무 생각없이 항상 체크해두던 옵션이 이럴 수가...

잡다한 인생님 홈페이지(http://electro-don.tistory.com/60)나 Keil 공식 사이트(http://www.keil.com/support/docs/3738.htm)에서의 설명으로는 라이브러리에서 사용하지 않는 함수 제거인데...

조금 더 공부를 해보아야겠습니다.

언제 초보딱지를...... ㅠㅠㅠㅠㅠㅠㅠ

 

Removing unused functions from a library: The major issue with removing unused functions in libraries is that the library object files are already compiled and usually the compiler will pack all functions of one module into a common section. So the linker can only remove this entire section, if all functions in this section are unused.

In order to remove some unused functions in this case, the library objects need to be build with "--split_sections" (there is a check box One ELF Section per Function in Options for Target - C/C++ to enable it). This option will put each function of a module in its own section. So the linker is able to remove each individual function, because it is in its own section. So enabling this for your library will allow the linker to remove unused functions from the library.

 

 

 

 

 

static const U8 _HotImage[54619] = {
  0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x01, 0x2C, 0x01, 0x2C, 0x00, 0x00, 0xFF, 0xE1, 0x0F, 0x0D, 0x45, 0x78, 0x69, 0x66, ..............

}

 


static int APP_GetData1(void * p, const U8 ** ppData, unsigned NumBytes, U32 Off) {
  *ppData = &_HotImage[Off];

  return NumBytes;
}

int main(void)
{
 /* Initialize system */
 SystemInit();
 
 USART_Init(USART1, TM_USART_PinsPack_1, 115200);
 
 RCC_GetClocksFreq(&SYS_Clocks);
 UART1_printf("\r\nSYSCLK:%dM\r\n",SYS_Clocks.SYSCLK_Frequency/1000000);
 UART1_printf("HCLK:%dM\r\n",SYS_Clocks.HCLK_Frequency/1000000);
 UART1_printf("PCLK1:%dM\r\n",SYS_Clocks.PCLK1_Frequency/1000000);
 UART1_printf("PCLK2:%dM\r\n",SYS_Clocks.PCLK2_Frequency/1000000); 
 UART1_printf("\n\r DCMI Example\n\r");
 
GUI_Init();

 while (1) {
  GUI_JPEG_DrawEx(APP_GetData1, 0, 0, 0);
  UART1_printf("\n\r APP_GetData1 Example\n\r");
  /* Delay 100ms */
  GUI_Delay(2000);
 }

}