Jump to content
    

MicroBlaze (мусор в стеке вызовов)

Приветствую.

При старте программы MicroBlaze и остановке на main() наблюдаю непонятное содержимое в стеке вызовов. Может кто сталкивался с подобным поведением и с чем оно связано?

Думал это связано с С++ проектом, но нашёл аналогичную проблему и для проекта на С тут.

Использую Vivado/SDK 2018.2, думал ситуация изменится при использовании Vitis 2020.1, но не помогло.

2.png

Share this post


Link to post
Share on other sites

А если в настройках Debug configuration поставить галочку Reset entire system, результат какой будет?

Share this post


Link to post
Share on other sites

12 hours ago, Strob said:

А если в настройках Debug configuration поставить галочку Reset entire system, результат какой будет?

Не меняется ничего.

Share this post


Link to post
Share on other sites

Нашёл такую особенность, если в настройках компилятора установить  Debug Level -> None (-g0), то картинка меняется.

Баг SDK???

Screenshot from 2020-07-29 16-44-03.png

Share this post


Link to post
Share on other sites

Пока проблему вижу в Xilinx SDK (может быть можно как-то настроить?). В настройках проекта в дефолтном состоянии установлены  флаги для компилятора -ffunction-sections -fdata-sections и линкера --gc-sections (Enable garbage collector), которые и приводят к данной проблеме.

Для кода
 

int TestFunction(int x1, int x2);

int main()
{
	while(1)
	{

	}
	return 0;
}

int TestFunction(int x1, int x2)
{
	return x1 + x2;
}

c установленными в опциях проекта галками Enable garbage collector получаем следующее в elf-файле

Disassembly of section .vectors.reset:

00000000 <_start>:
	}
	return 0;
}

int TestFunction(int x1, int x2)
{
   0:	b0000000 	imm	0
   4:	b8080050 	brai	80	// 50 <_start1>

Disassembly of section .vectors.sw_exception:

00000008 <_vector_sw_exception>:
   8:	b0000000 	imm	0
   c:	b808095c 	brai	2396	// 95c <_exception_handler>

Disassembly of section .vectors.interrupt:

00000010 <_vector_interrupt>:
  10:	b0000000 	imm	0
	return x1 + x2;
  14:	b80809d0 	brai	2512	// 9d0 <__interrupt_handler>

Disassembly of section .vectors.hw_exception:

00000020 <_vector_hw_exception>:
}
  20:	b0000000 	imm	0
  24:	b80802f0 	brai	752	// 2f0 <_hw_exception_handler>

Disassembly of section .text:

если убрать разрешение Enable garbage collector, то всё сразу круто (за исключением размера бинарника)

Disassembly of section .vectors.reset:

00000000 <_start>:
   0:	b0000000 	imm	0
   4:	b8080050 	brai	80	// 50 <_start1>

Disassembly of section .vectors.sw_exception:

00000008 <_vector_sw_exception>:
   8:	b0000000 	imm	0
   c:	b808099c 	brai	2460	// 99c <_exception_handler>

Disassembly of section .vectors.interrupt:

00000010 <_vector_interrupt>:
  10:	b0000000 	imm	0
  14:	b8080a00 	brai	2560	// a00 <__interrupt_handler>

Disassembly of section .vectors.hw_exception:

00000020 <_vector_hw_exception>:
  20:	b0000000 	imm	0
  24:	b8080330 	brai	816	// 330 <_hw_exception_handler>

Disassembly of section .text:

Криво сформированный elf-файл и приводит к тому, что SDK (если в Debug Configurations поставить галку Stop at program entry) отображает выполнение кода, который не должен был выполняться (реально выполняется startup sequence crt0.S).

Как исправить - вопрос открытый.

 

Screenshot from 2020-07-30 17-57-40.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...