链接脚本使用一例1

出于对链接脚本的兴趣,准备试试,在PC上用链接脚本写一个测试程序,跟uboot中的不同。

这里有两个文件t2.c和load.lds

t2.c

#include <stdio.h>

char __attribute__((section(".peng"))) ch[20] = "pengdonglin137";

extern unsigned int __peng_start;

char *p = (char *)(&__peng_start);
//我们要获取__peng_start的存放地址,作为字符串首地址,或者数组名来使用。
int main(int argc, const char *argv[])
{
    int i;

    printf("%s
", (&__peng_start));

    for(i=0; p[i] != '