???????C/C++??????
???????????? ???????[ 2015/11/19 10:48:59 ] ????????.NET ???????????
??????.?????????????????????
????1.??VC IDE?У?????????????[Project]|[Settings]??c/c++???Category??Code Generation????Struct Member Alignment???????????8????
????2.???????????????????????#pragma pack .???:??pragma??????progma.
??????.?????????????????????ο????
?????????????????????????????????????????????????????0??????????????????????????????м??????????????????е???????? ?????С??С???????????????????м???????.???????????????任?????Ч??????????????????????ж???????:?????????任????? ????????????reserved?????
????struct A{
????char a;
????char reserved[3];//????任???
????int b;
????}
????reserved?????????????????????壬???????????????????????????????????????????????????????????????????????????????????????????????????.
??????.??????????????????:
?????????й????????????????????????????????????????????????磺
????unsigned int i = 0x12345678;
????unsigned char *p=NULL;
????unsigned short *p1=NULL;
????p=&i;
????*p=0x00;
????p1=(unsigned short *)(p+1);
????*p1=0x0000;
???????????????????????????unsignedshort????????????????????漲??
??????x86?????????????????Ч?????????MIPS????sparc????????????error?????????????????????.
??????.??β??????????????????:
????????????????????????????
????1. ????????big little??????
????2. ??????????????????????????
????3. ??????????????????????????????????????Щ????????????????????????????
??????.ARM?μ??????
????from DUI0067D_ADS1_2_CompLib
????3.13 type qulifiers
?????в??????ARM???????????????
????????????:
????1.__align(num)
??????????????????????????硣?????????LDRD????STRD?
??????????????__align(8)??????????????????????????????????
??????????ζ???????????8????????????????2??????????4???
?????????????????4???????2??????
????__align??洢????????????θ???????????????????????????
????2.__packed
????__packed????????????
????1.?????packed???????ж???
????2.???ж?????д????????з???????
????3.float??????float????????δ??__packed???????????????
????4.__packed???????α????????
????5.?????unpacked??????packed?????????δ???壬??????????????
???????packed??
????__packed int* p; //__packed int ?????????
????6.??????????д???????????
????__packed struct STRUCT_TEST
????{
????char a;
????int b;
????char c;
????} ; //????????????b???????????????????
????//????з???b??????????????????????????????[from CL]
????//??????????????????????????
????static char* p;
????static struct STRUCT_TEST a;
????void Main()
????{
????__packed int* q; //????????__packed?????ε??q?????????????????????????????
????p = (char*)&a;
????q = (int*)(p+1);
????*q = 0x87654321;
????/*
?????????????????????
????ldr r5??0x20001590 ; = #0x12345678
????[0xe1a00005] mov r0??r5
????[0xeb0000b0] bl __rt_uwrite4 //???????????д4byte?????????
????[0xe5c10000] strb r0??[r1??#0] //????????4??strb?????????????????????????
????[0xe1a02420] mov r2??r0??lsr #8
????[0xe5c12001] strb r2??[r1??#1]
????[0xe1a02820] mov r2??r0??lsr #16
????[0xe5c12002] strb r2??[r1??#2]
????[0xe1a02c20] mov r2??r0??lsr #24
????[0xe5c12003] strb r2??[r1??#3]
????[0xe1a0f00e] mov pc??r14
????*/
????/*
???????q??м?__packed???????????????????????????????????????
????[0xe59f2018] ldr r2??0x20001594 ; = #0x87654321
????[0xe5812000] str r2??[r1??#0]
????*/
????//?????????????????????????????β????????
????//?????????????????????????
????//????????????????????????????????Ч??????
????}
??????.ARM?μ???δ??????????
????from http://blog.csdn.net/alenwelkin/archive/2006/12/19/1448324.aspx
???????б?д????????????????char?????????£?
????char p[] = {0x10?? 0x20?? 0x30?? 0x40?? 0x50?? 0x60?? 0x70?? 0x80};
?????????long???short?????????p+3??λ?????????????????0x10963?????????????long??short????????????????
?????????????????£??????????????????????
????/mnt ?? ./test
????l 0x10963(0x30201040)?? s 0x10963(0x5040)?? lt 0x30201040?? st 0x5040
???????arm-linux-objdump????????????????????????short????????????????????????????????????????????long??????????
????unsigned long *l = (p + 3);
????83e0: e59f3084 ldr r3?? [pc?? #132] ; 846c <.text+0x190>
????83e4: e50b3010 str r3?? [fp?? #-16]
????unsigned short *s = (p + 3);
????83e8: e59f307c ldr r3?? [pc?? #124] ; 846c <.text+0x190>
????83ec: e50b3014 str r3?? [fp?? #-20]
????unsigned long lt = *l;
????83f0: e51b3010 ldr r3?? [fp?? #-16] //????l->r3
????83f4: e5933000 ldr r3?? [r3] //l????->r3
????83f8: e50b3018 str r3?? [fp?? #-24] //r3->lt
????unsigned short st = *s;
????83fc: e51b3014 ldr r3?? [fp?? #-20] //????s->r3
????8400: e5d32000 ldrb r2?? [r3] //s???????λ??->r2
????8404: e5d33001 ldrb r3?? [r3?? #1] //s???????λ??->r3
????8408: e1823403 orr r3?? r2?? r3?? lsl #8 //r3???????r2????short?->r3
????840c: e54b301a strb r3?? [fp?? #-26] //r3?е?short?(??λ)->????st??λ
????8410: e1a03443 mov r3?? r3?? asr #8 //r3????8λ->r3
????8414: e54b3019 strb r3?? [fp?? #-25] //r3?е?short?(??λ)->????st??λ
????0x30201040?????????????????????????
????????ARM????鼮????????Э??????CP15:c1:c0?е?1λ??22λ???0????ARM???ldr????????memory(addr & ~3?? 4) ROR ((addr & 3) * 8)?????????????4?????????????????????0x10960????????????? 0x40302010??????????????????????24λ????????????0x40302010 ROR 24 ?? 0x30201040??????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????