Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gcc 链接器脚本中的位置计数器(.)更新_Gcc_Counter_Ld_Linker Scripts - Fatal编程技术网

Gcc 链接器脚本中的位置计数器(.)更新

Gcc 链接器脚本中的位置计数器(.)更新,gcc,counter,ld,linker-scripts,Gcc,Counter,Ld,Linker Scripts,链接器脚本中的位置计数器有问题。不知道这是一个bug还是我期望的输出错误 我有一个bss部门 /* Program bss, zeroed out during init. */ .bss : { . = ALIGN(4); __bss_start = .; *(.bss*) *(.COMMON*) . = ALIGN(4); __bss_end = .; __heap_start = .; } >sram_u __bss_size

链接器脚本中的位置计数器有问题。不知道这是一个bug还是我期望的输出错误

我有一个bss部门

/* Program bss, zeroed out during init. */
.bss :
{
    . = ALIGN(4);
    __bss_start = .;
    *(.bss*)
    *(.COMMON*)
    . = ALIGN(4);
    __bss_end = .;
    __heap_start = .;
} >sram_u
__bss_size = SIZEOF(.bss);
我的问题是(uu bss_end-u bss_start)不等于u bss_size。如果我改为在.bss节外指定uu_bss_end,则会得到预期值。如果我用elfread检查节标题,我会得到预期的.bss大小

我使用的链接器是:

GNU ld (GNU Tools for ARM Embedded Processors) 2.23.2.20131129
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
和海湾合作委员会

arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release)
[ARM/embedded-4_8-branch revision 205641]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
所以问题是位置计数器(.)是应该在节定义中更新,还是我只是用错了


PS:希望我使用的是正确的术语…

很抱歉没有早点回复

问题是有一个问题。在普通之前。链接器脚本应该是

.bss :
{
    . = ALIGN(4);
    __bss_start = .;
    *(.bss*)
    *(COMMON*)
    . = ALIGN(4);
    __bss_end = .;
    __heap_start = .;
} >sram_u
__bss_size = SIZEOF(.bss);
我在查看地图文件时也漏掉了一些东西。链接器将在bss中将公共设置为默认设置,但这不会被.bss部分内的uu bss_end看到。将_bss_end移动到bss节声明之外将捕获它。通过将-fno COMMON添加到gcc中删除了公共块