gpt4 book ai didi

c编译器,重叠内存错误

转载 作者:太空宇宙 更新时间:2023-11-04 02:43:54 25 4
gpt4 key购买 nike

下面是我正在使用的 C 代码的一部分:

pushbutton_ISR()
{

int press;
int key_pressed;

press = *(KEYS_ptr + 3); // read the pushbutton Edge Det Register interrupt register
*(KEYS_ptr + 3) = 0; // Clear the Edge Det registers.

if (press & 0x1) { // KEY1
key_pressed = KEY1;
//sum = sum + *NEW_NUMBER;
}
else if (press & 0x2) { // KEY2
key_pressed = KEY2;
*GREEN_LEDS = *NEW_NUMBER;
sum = sum + *NEW_NUMBER;
*RED_LEDS = sum;
}
else // i.e. (press & 0x8), which is KEY3
sum = *(NEW_NUMBER); // Read the SW slider switch values; store in pattern

return;
}

编译器可以很好地编译此代码,并且代码似乎可以正常运行(在 Altera 开发板上)。但是,当我将第一个 if 语句更改为:

if (press & 0x1) {                      // KEY1
//key_pressed = KEY1;
sum = sum + *NEW_NUMBER;
}

编译器给出以下错误信息:

.../nios2-elf/bin/ld.exe: section .data loaded at [00000a00,00000e0f] overlaps section .text loaded at [00000500,00000a0f]
.../nios2-elf/bin/ld.exe: section .ctors loaded at [00000a10,00000a13] overlaps section .data loaded at [00000a00,00000e0f]
.../nios2-elf/bin/ld.exe: Z:/Projects/Altera/3215_W15_LabB/Part2/from_handout.elf: section .data vma 0xa00 overlaps previous sections
.../nios2-elf/bin/ld.exe: Z:/Projects/Altera/3215_W15_LabB/Part2/from_handout.elf: section .ctors vma 0xa10 overlaps previous sections
.../nios2-elf/bin/ld.exe: Z:/Projects/Altera/3215_W15_LabB/Part2/from_handout.elf: section .rodata vma 0xa14 overlaps previous sections
.../nios2-elf/bin/ld.exe: Z:/Projects/Altera/3215_W15_LabB/Part2/from_handout.elf: section .sdata vma 0xe10 overlaps previous sections
.../nios2-elf/bin/ld.exe: Z:/Projects/Altera/3215_W15_LabB/Part2/from_handout.elf: section .sbss vma 0xe18 overlaps previous sections

能否请您告诉我这些错误的原因以及解决方法。

最佳答案

这与您的代码不正确无关。

这些是关于输出部分重叠的链接器错误(它甚至告诉您 ld.exe 是程序在提示)。这可能 意味着您刚刚用完了空间,但也可能意味着您的项目正在使用的链接器指令文件存在一些问题。

关于c编译器,重叠内存错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29257469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com