Sun SPARC 内存存储模式

26 篇文章 0 订阅

Sun SPACK 是big-endian

 

 

host{/u/XXX/memLeak}:cat t.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
    int *pi = 0;

    long *pl = 0;

 

    char *p1 = (char *)malloc(40);  printf("p1 = %lx/n",p1);
    memset(p1,0,40);
    char * constStr="012345678901234567890123456789";
    memcpy(p1,constStr,strlen(constStr));


    char *p2 = (char *)malloc(40);  printf("p2 = %lx/n",p2);
    memset(p2,0,40);
    pi = (int *)p2;
    (*pi) = 0x12;


    char *p3 = (char *)malloc(40);  printf("p3 = %lx/n",p3);
    memset(p3,0,40);
    pi = (int *)p3;
    (*pi) = 0x1234;

 

    char *p4 = (char *)malloc(40);  printf("p4 = %lx/n",p4);
    memset(p4,0,40);
    pl = (long*)p4;
    (*pl) = 0x12345678;
    printf("%s/n",0);

 

    char *p5 = (char *)malloc(40);  printf("p5 = %lx/n",p5);
    memset(p5,0,40);
    pl = (long*)p5;
    (*pl) = 0x1234567890;
    printf("%s/n",0);

 

 

    printf("%s/n",0);
}


host{/u/XXX/memLeak}:cc -xarch=v9 t.c
host{/u/XXX/memLeak}:./a.out
p1 = 100100eb0
p2 = 100100ef0
p3 = 100100f30
Segmentation Fault(coredump)


host{/u/XXX/memLeak}:mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
> 100100eb0/10X    // char * p = "01234567890123456789";
0x100100eb0:           30313233        34353637        38393031        32333435        36373839        
                                 30313233        34353637        38390000        00000000        00000000
> 100100ef0/10X    // int * p = 0x12;
0x100100ef0:           00000012        00000000        00000000         00000000        00000000
                                 00000000        00000000        00000000         00000000        00000000    
> 100100f30/10X    // int * p = 0x1234;
0x100100f30:           00001234        00000000        00000000         00000000        00000000           
                                 00000000        00000000        00000000         00000000        00000000              
>

> 100100f70/10X    // long * p= 0x12345678;
0x100100f70:           00000000      12345678         00000000          00000000       00000000      
                                 00000000      00000000          00000000         00000000       00000000 

 

> 100100f70/10X    // long * p = 0x1234567890;
0x100100f70:           00000012      34567890          00000000        00000000        00000000    
                                 00000000      00000000          00000000        00000000        00000000

 

=====================

Memory address

    ---------> enlarge

    |

    |

   V

enlarge

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值