This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430FR2355:DWARF 错误:行信息数据比部分剩余的空间(0x50)更大(0xfffffffc)

Guru**** 2386610 points
Other Parts Discussed in Thread: MSP430FR2355
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1452179/msp430fr2355-dwarf-error-line-info-data-is-bigger-0xfffffffc-than-the-space-remaining-in-the-section-0x50

器件型号:MSP430FR2355

工具与软件:

当我在 Linux 命令行(Fedora FC41)上使用 MSP430-gcc 编译一个简单的闪烁程序时、它的工作方式就像 Charm 一样:

#include <msp430.h>

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer
    
    P3OUT &= ~BIT0;					// LED Status (Red)
    P3DIR |= BIT0;		

    PM5CTL0 &= ~LOCKLPM5;           // Disable the GPIO power-on default high-impedance mode
    
    while(1)
    {
        P3OUT ^= BIT0;  
        __delay_cycles(500000);             
    }
}

但是、一旦我将初始化代码放入头文件中:

#include <msp430.h>
#include "init.h"

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    init();
    
    while(1)
    {
        P3OUT ^= BIT0;                    
        __delay_cycles(500000);            
    }
}

init.c

#include <msp430.h>
#include "init.h"

void init(void)
{	
	P3OUT &= ~BIT0;					// LED Status (Red)
	P3DIR |= BIT0;		

	PM5CTL0 &= ~LOCKLPM5;           // Disable the GPIO power-on default high-impedance mode
}

init.h:

#ifndef ESM_H_
#define ESM_H_


#endif /* ESM_H_ */

它会显示错误消息:  

../../msp430-elf/bin/ld:DWARF 错误:行信息数据大于该段中剩余的空间(0xfffffffc)

我缺少什么? (使用 CCS 时、它可以正常工作、只是不在命令行上)。  Makefile 中的所有路径似乎都可以。

下面是我的 Makefile:

OBJECTS = main.o
MAP = main.map

GCC_DIR = /opt/ti/msp430-gcc/bin
SUPPORT_FILE_DIRECTORY = /opt/ti/msp430-gcc/include

DEVICE  = MSP430FR2355
CC      = $(GCC_DIR)/msp430-elf-gcc
GDB     = $(GCC_DIR)/msp430-elf-gdb
OBJCOPY = $(GCC_DIR)/msp430-elf-objcopy

CFLAGS = -I $(SUPPORT_FILE_DIRECTORY) -I. -mmcu=$(DEVICE) -ffunction-sections -fdata-sections -Og -Wall -g -DDEPRECATED -v
LFLAGS = -L $(SUPPORT_FILE_DIRECTORY) -Wl,-Map,$(MAP),--gc-sections 

.PHONY: all clean debug

all: $(DEVICE).out

$(DEVICE).out: $(OBJECTS)
	$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
	$(OBJCOPY) -O ihex $@ $(DEVICE).hex

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

clean: 
	$(RM) $(OBJECTS) $(MAP) *.out *.hex

debug: all
	$(GDB) $(DEVICE).out

非常感谢您的帮助!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    必须有更多的。 第一、警告。

    通常在 init.h 中包含 init ()的函数原型,以防止编译器发出声音。

    但仅在 makefile 的对象行中列出 main.o 意味着不会编译或链接 init.c。 所以 init()将会丢失、链接器应该会抱怨这一点。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您可以尝试 按如下方式修改 init.h

    #ifndef ESM_H_
    #define ESM_H_

    void init (void);


    #endif /* ESM_H_*/

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    对此深表歉意。 当然、您是对的。 我的错。 我在另一个程序的 init.h 中有原型、在这个示例中忘记了。  

    不过、遗憾的是、它无法解决问题。 这是完整的输出:

    Sage@Fedora:~/workspace/fwTesting make.
    /opt/ti/msp430-gcc/bin/msp430-elf-gcc -i /opt/ti/msp430-gcc/include -i. -mmcu=MSP430FR2355 -ffunfunction-SECTIONS -fdata-sections -og -Wall -g -DDEPRECATED -v -L /opt/ti/msp430-gcc/include -WL、-Map、main.map、--gc-sections main.o -o MSP430FR2355.out
    安全连接。
    collect_gcc=/opt/ti/msp430-gcc/bin/msp430-elf-gcc
    collect_lto_wrapper=/opt/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1/lto-wrapper
    目标:msp430-elf
    配置如下:../target=msp430-elf /../gcc/configure --enable-languages=c、c++--disable-nls --enable-initfini-array --build=x86_64-PC-linux-gnu --host=x86_64-PC-linux-gnu --enable-target-optspace --enable-newlib-nano-formated-io --with-pkgSystems - msp430-limit-version=msp430-gnu - msp430-g9.3.11.1.11'
    Thread 模型:单个
    GCC 9.3.1版(Mitto Systems Limited - MSP430-gcc 9.3.1.11)
    Compiler_path=/opt/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1:/opt/ti/msp430-gcc/bin/../libexec/gcc:/opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin
    library_path=/opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1:/opt/ti/msp430-gcc/bin/../lib/gcc:/opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib
    collect_gcc_options='-i''/opt/ti/msp430-gcc/include '-i'。' '-mmcu=msp430fr2355''-ffunfunction-sections''-fdata-sections''-og''-wall''-g''-d''DEPRECATED''-v''/opt/ti/mcc/gcc/include''M05430FR2355.out''-mdevices-csv2'=msp430loc-cpu'/opt/ti/msp430-gcc/include/devices.csv /opt/ti/msp430-gcc/include/devices.csv
    /opt/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1/collect2 /opt/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1/liblto_plugin.so /lib/gcc -gnos-gc -plugin-opt=msp430-opt=-fresolution=/tmp/ccQRlE87.res -plugin-opt=-pass-through =-lgcc -plugin-opt=-pass-through=-lmul_f5 /opt/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1/lto-wrapper /opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib/crt0.o /opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/crtbegin_no_eh.o /lib/gcc/msp430-elf/9.3.1 /lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib /opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/crtend_no_eh.o
    /opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld:/opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld:DWARF 错误:行信息数据大于该段中剩余的空间(0xfffffffc)
    main.o:在函数`.Loc.8.1'中:
    main.c:(.text.main+0x8):对`init '的未定义引用
    collect2:错误:LD 返回1个退出状态
    make:***[Makefile:20:MSP430FR2355.OUT]错误1.
    Sage@Fedora:~/workspace/fwTesting

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    侧重于警告、不注意错误:

    "main.c:(.text.main+0x8):对`init '的未定义引用"

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

     `的假设是、对"init"的未定义引用是 由 DWARF 误差引起的。 链接器在这里停止链接。 (我们仍然不知道为什么会发生这个 DWARF 误差)。 我发现了一些 关于旧错误的信息: sourceware.org/.../show_bug.cgi

    作为错误修复、建议修改特定 MSP430 (在我的案例中为 msp430fr2355.ld)的链接器脚本:

    .debug_line 0:{*(.debug_line)}
    
    (可能接近脚本末尾)。 将其替换为以下行:
    
    .debug_line 0:{*(.debug_line .debug_line.*.debug_line_end)} 

    但在我的链接器脚本中、它已经类似于下面的行、因此这已经修复了。
    现在我的想法已经过时了...
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    makefile 说明 make 程序包含单个对象:main.o. 当您将一个项目拆分为多个文件时、必须通过 makefile 来描述这一点。

    将第一行从:

    objects = main.o

    收件人:

    objects = main.o init.o

    您还有一个潜在的问题、即您尚未将 init.h 作为 main.o.

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    OBJECTS = main.o init.o 完成了该作业。

    谢谢大卫! 我确实被这个奇怪的 DWARF 误差蒙蔽了。