将常量转换为指针会增加 .data 大小 1000 字节

问题描述 投票:0回答:1

我对这个完全不知所措,我什至不知道我的问题要包含什么。

当我将常量转换为指针时,我的 (.data + .bss + .noinit) 部分增长了 1K,超出了 ATmega328P 的容量。

PK16_TABLE_T* pk16_find_table_by_index(PK16_T* p_pkg, SIZE_T index)
{
    SIZE_T offset;
    PK16_TABLE_T* p_table;

    p_table = (PK16_TABLE_T*) 0;

    return p_table;
}

如果我投射一个指针,那么数据大小保持不变,不会增长 1K:

PK16_TABLE_T* pk16_find_table_by_index(PK16_T* p_pkg, SIZE_T index)
{
    SIZE_T offset;
    PK16_TABLE_T* p_table;

    p_table = (PK16_TABLE_T*) &offset;

    return p_table;
}

我从哪里开始调试这个?您还需要查看什么才能了解可能发生的情况?

/** A single entry in a PK16 package. */
typedef struct {
    /** Null-terminated string representing the path of this entry. */
    CHAR_T path[PK16_MAX_PATH_LEN];
    /** Index into the package data buffer of the start of this entry's data. */
    U16_T head;
    /** Length in bytes of this entry's data in the data buffer. */
    U16_T len;
    /** CRC32 of this entry's path + data. */
    U32_T crc;
} PK16_TABLE_T;
c arduino avr arduino-uno avr-gcc
1个回答
0
投票

评论中有人帮我解决了这个问题,但他们出于某种原因删除了评论。

我用

readelf
来分析添加了什么符号。

这是CRC32多项式表!我不知道为什么常量转换决定是否包含该符号,但这就是答案。

© www.soinside.com 2019 - 2024. All rights reserved.