
¢¬ ÁȤ߹þ¤ßlinux¥Ü¡¼¥É¥³¥ó¥Ô¥å¡¼¥¿¤ò¤ªÃµ¤·¤ÎÊý¤Ï¤´¸¡Æ¤¤¯¤À¤µ¤¤. ¼«¿®¤ò»ý¤Ã¤Æ¤ª´«¤á¤·¤Þ¤¹. ¢¬
![]() ¥±¡¼¥¿¥¤¤Ç¤â¤¨¤Ó¤á¤â |
Áȹþ¤ßlinux²° ebichan¤Î linux hackµÏ¿¡¢CAT760³«È¯µÏ¿¡¢¥µ¡¼¥Ð¥á¥ó¥ÆµÏ¿¡¢ Link¥Õ¥ê¡¼ / ÆÍ¤Ã¹þ¤ß´¿·Þ SPAMÂкö¤Î¤¿¤áÆÍ¤Ã¹þ¤ß¤ËURL¤Ïޤì¤Þ¤»¤ó¤Î¤Ç²Ã¹©¤·¤ÆÅ½¤Ã¤Æ¤¯¤À¤µ¤¤ ¤³¤Î¥Ú¡¼¥¸¤Ïebichan¤Î¸Ä¿ÍŪ¤Ê¥Ú¡¼¥¸¤Ç¤¹ ½ê°²ñ¼Ò¤ÎÊý¿Ë¤ò¼¨¤¹¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡Ê¡°¡Ý¡° Twitter @ebihara_nagoya |
º£Æü¤ÎˬÌä¼Ô ºòÆü¤ÎˬÌä¼Ô º£¤Þ¤Ç¤ÎˬÌä¼Ô ºÇ¶á¤Î¥Ä¥Ã¥³¥ß |
|
2012|01|
|
¤¨¤Ówiki ¤ä¤ê¤¿¤¤¤³¤È ²áµîÌܼ¡ |
boss3 core7:~# mkfs.ext3 /dev/sdb2 -v
mke2fs 1.41.12 (17-May-2010)
fs_types for mke2fs.conf resolution: 'ext3', 'default'
Calling BLKDISCARD from 0 to 100002951168 failed.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6111232 inodes, 24414783 blocks
1220739 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
746 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Calling BLKDISCARD ¤¬ failed ¤Ë¤Ê¤ë¤¬¡¢´Ø·¸Ìµ¤¤¤é¤·¤¤¡£
SH4¤Çmkfs.ext3¤¹¤ë¤È¼Â¹Ô³«»Ï¤µ¤ì¤Ê¤¤
supercat:~# mkfs.ext3 /dev/mmcblk0p2 -v mke2fs 1.41.12 (17-May-2010) fs_types for mke2fs.conf resolution: 'ext3', 'default' Calling BLKDISCARD from 0 to 3500982272 failed. supercat:~#¤Ç½ª¤ï¤Ã¤Æ¤·¤Þ¤¦
util-linux¤òºî¤ê¤Ê¤ª¤·¡¢libblkid, libuuid1 ¤òÆþ¤ìľ¤·¤¿¤éľ¤Ã¤¿
#include¥Ó¥ë¥É&¥é¥ó#define SIZE_1M (1024*1024) #define LIMIT 4096 int main(){ int *p; int i; for(i=0; i < LIMIT; i++){ p=malloc(SIZE_1M); if(p==NULL){ printf("NIL\n"); perror(""); return 1; } memset(p,i,SIZE_1M); printf("%d Mbyte\n",i); } }
$ sh4-linux-gnu-gcc malloc_test.c -static $ qemu-sh4 ./a.out ¤¶¤Ã¤¯¤ê¤Èά 1526 Mbyte 1527 Mbyte 1528 Mbyte 1529 Mbyte qemu: uncaught target signal 11 (Segmentation fault) - core dumped Segmentation fault¤Ê¤ï¤±¤Ç ¤ª¤è¤½1.5G¤Ç»à¤Ì¡£ Â絬Ìϥѥ屡¼¥¸¤Î¥ê¥ó¥¯¹©Äø¤Ê¤É¤Ç1.5G¤Ç¤Ï¥á¥â¥ê¤¬Â¤ê¤Ê¤¤¤³¤È¤¬¤¢¤ë¡£qemu¤Î¥É¥¥å¥á¥ó¥È¤ò¸«¤ë¤È -R ¥ª¥×¥·¥ç¥ó¤Ç²óÈò¤Ç¤¤ë¤è¤¦¤À¡£
$ qemu-sh4 -R 4G ./a.out (4G¤ò¥ê¥¶¡¼¥Ö¤¹¤ë) 4092 Mbyte 4093 Mbyte 4094 Mbyte 4095 Mbyteqemu¤Î¥½¡¼¥¹¥³¡¼¥É¤ò¸«¤ë¤È¡¢»öÁ°¤Ë -R ¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤷ¤¿ reserved_va ¥µ¥¤¥º¤À¤± mmap()¤¹¤ë¤è¤¦¤À¡£
--- linux-user/main.c-orig 2011-08-04 11:45:43.000000000 +0000
+++ linux-user/main.c 2011-08-04 11:45:14.000000000 +0000
@@ -2941,40 +2941,44 @@
#endif
}
cpu_exec_init_all(0);
/* NOTE: we need to init the CPU at this stage to get
qemu_host_page_size */
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
cpu_reset(env);
#endif
thread_env = env;
if (getenv("QEMU_STRACE")) {
do_strace = 1;
}
+ if (getenv("QEMU_4G")){
+ reserved_va = 0xffffffff;
+ }
+
target_environ = envlist_to_environ(envlist, NULL);
envlist_free(envlist);
»È¤Ã¤Æ¤ß¤ë
qemu-sh4 ¤ò»È¤Ã¤ÆÆ°¤¤¤Æ¤¤¤ë sh4 debian ¤Î chroot Æâ¤Ç $ export QEMU_4G=1 »ØÄê $ ./a.out ¤¶¤Ã¤¯¤êά 4092 Mbyte 4093 Mbyte 4094 Mbyte 4095 Mbyte $ export -n QEMU_4G ²ò½ü¤Ð¤Ã¤Á¤ê
/usr/lib/gcc/sh4-linux-gnu/4.3.2/../../../libcairo.so: undefined reference to `__sync_val_compare_and_swap_4'path¤¬¾éŤÀ¤¬/usr/lib/libcairo.so.2.17.5¤ËÌäÂ꤬¤¢¤ë
readelf -s /usr/lib/libcairo.so.2.17.5 | grep __sync
32: 00000000 0 NOTYPE GLOBAL DEFAULT UND __sync_val_compare_and_sw
¥·¥ó¥Ü¥ë¤Îɽ¼¨¤¬ÅÓÀÚ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¤¬¡¢³ºÅö¤Î´Ø¿ô¤¬undefined¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
$ nm src/.libs/libcairo.so | grep __sync
0006607c t __sync_compare_and_swap_1
00066094 t __sync_compare_and_swap_2
000660ac t __sync_compare_and_swap_4
000660c4 t __sync_fetch_and_add_1
000660d8 t __sync_fetch_and_add_2
000660ec t __sync_fetch_and_add_4
0006613c t __sync_fetch_and_and_1
00066150 t __sync_fetch_and_and_2
00066164 t __sync_fetch_and_and_4
000661fc t __sync_fetch_and_nand_1
00066214 t __sync_fetch_and_nand_2
0006622c t __sync_fetch_and_nand_4
00066100 t __sync_fetch_and_or_1
00066114 t __sync_fetch_and_or_2
00066128 t __sync_fetch_and_or_4
000661b4 t __sync_fetch_and_sub_1
000661cc t __sync_fetch_and_sub_2
000661e4 t __sync_fetch_and_sub_4
00066178 t __sync_fetch_and_xor_1
0006618c t __sync_fetch_and_xor_2
000661a0 t __sync_fetch_and_xor_4
00066040 t __sync_lock_test_and_set_1
00066054 t __sync_lock_test_and_set_2
00066068 t __sync_lock_test_and_set_4
U __sync_val_compare_and_swap_4
¾¤Îgcc´Ø¿ô¤ÏÄêµÁºÑ¤ß¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤¬¡¢¤Ò¤È¤Ä¤À¤± U ¤Î¤Þ¤Þ¤Ç¤¢¤ë¡£cairo¤Î¥Ð¥°¤òÅö¤¿¤Ã¤Æ¤ß¤ë¡£
¤È¤¤¤¦¤³¤È¤Ç¡¢¥½¡¼¥¹¥Ñ¥Ã¥±¡¼¥¸Ä¾²¼¤Î configure ¤ò½¤Àµ¤¹¤ë»ö¤ÇÂн褷¤¿
$ vi configure
...
/* end confdefs.h. */
int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
int atomic_int_cmpxchg(int i, int j, int k) { return__sync_val_compare_and_swap(&i, j, k); } ¢¨¤³¤Î¹Ô¤òÄɵ¤¹¤ë¡£
int
main ()

