Hi there,
I'm having trouble by using symbols defined in a linker script in my source file.
In the linker script, I define symbols like:
PROVIDE(_nvarea_begin = 0x100 000 000);
. = _nvarea_begin;
PROVIDE(_nvdata_begin = . );
.nvdata . : { *(.nvdata) }
PROVIDE(_nvdata_end = . );
PROVIDE(_nvdata_size = SIZEOF(.nvdata));
And in a c++ source file, they are referred as:
extern "C" char _nvdata_begin[];
extern "C" char _nvdata_end[];
extern "C" char _nvdata_size[];
In this case, as I learn from this site (https://sourceware.org/binutils/docs/ld/Source-Code-Reference.html#Source-Code-Reference),
If I print the value of _nvdata_begin in the source file, it should be 0x100 000 000 ( printf("_nvdata_begin %p", _nvdata_begin) ).
And for _nvdata_end and _nvdata_size, they should also be the values set in linker script.
This works fine in Ubuntu 16.04 as the output is:
_nvdata_begin 0x100 000 000
_nvdata_end 0x101 000 850
_nvdata_size 0x1 000 850
But the output in Alpine (Vanilla - 3.7.0-x86_64) is very strange.
It looks like:
_nvdata_begin 0x564 a9f bf9 000
_nvdata_end 0x564 aa0 bf9 850
_nvdata_size 0x564 9a0 bf9 850
Every time I run the file, it gets different values (but _nvdata_end - _nvdata_begin = 0x1 000 850 is always correct).
When I use nm to check the symbols, all the values are correct showed:
_nvdata_begin 0x100 000 000
_nvdata_end 0x101 000 850
_nvdata_size 0x1 000 850
Can someone please tells me, why this happens and how to fix it? Thanks in advance.
Regards,
Yuxing
---
Unsubscribe: alpine-user+unsubscribe@lists.alpinelinux.org
Help: alpine-user+help@lists.alpinelinux.org
---