{"id":538,"date":"2013-02-18T22:14:19","date_gmt":"2013-02-18T13:14:19","guid":{"rendered":"http:\/\/43.203.250.216\/?p=538"},"modified":"2013-02-18T22:14:19","modified_gmt":"2013-02-18T13:14:19","slug":"binaryhack11-%ec%8b%a4%ed%96%89-%ed%8c%8c%ec%9d%bc%ec%97%90-%eb%8d%b0%ec%9d%b4%ed%84%b0-%ec%82%bd%ec%9e%85%ed%95%98%ea%b8%b0-64bits","status":"publish","type":"post","link":"https:\/\/litcoder.com\/?p=538","title":{"rendered":"[BinaryHack#11] \uc2e4\ud589 \ud30c\uc77c\uc5d0 \ub370\uc774\ud130 \uc0bd\uc785\ud558\uae30 (64bits)"},"content":{"rendered":"<p>&#8216;Binary Hacks&#8217;\uc758 hack #11\uc5d0\ub294 objcopy\ub97c \uc774\uc6a9\ud574\uc11c \uc2e4\ud589\ud30c\uc77c\uc5d0 binary\ub97c \ucd94\uac00\ud558\ub294 \ubc29\ubc95\uc774 \ub098\uc628\ub2e4. \uc774\uac83\uc744 \ub530\ub77c 64 bits machine\uc5d0\uc11c build\ud558\uba74 i386:x86-64 \ucd9c\ub825\ubb3c\uacfc i386 \ucd9c\ub825\ubb3c\uc774 incompatible \ud574\uc11c link\ud560 \uc218 \uc5c6\ub2e4\ub294 \uc624\ub958\uac00 \ubc1c\uc0dd\ud55c\ub2e4.<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$&gt; objcopy -I binary -O elf32-i386 -B i386 binary.bmp binary.o\n$&gt; gcc -c main.c\n$&gt; gcc -o program main.o binary.o\n\/usr\/bin\/ld: i386 architecture of input file 'binary.o' is incompatible with i386:x86-64 output\ncollect2: error: ld returned 1 exit status<\/pre>\n<p>gcc\ub85c \ub9cc\ub4e4\uc5b4\uc9c4 main.o\ub294 ELF-64 format\uc778\ub370 objcopy\ub85c \uc0dd\uc131\ud55c ELF-32 format\uc774\uc5b4\uc11c \ud568\uaed8 link\ud560 \uc218 \uc5c6\ub2e4\ub294 \uac83\uc774\ub2e4. \uc774 \ubb38\uc81c\ub294 \ub3d9\uc77c\ud55c ELF format\uc774 \ub418\ub3c4\ub85d \ud558\uba74 \ud574\uacb0\ub41c\ub2e4. \uc989, gcc\ub85c compile\ud55c \uacb0\uacfc\ubb3c\uc774 objcopy\uc758 \uacb0\uacfc\ubb3c\uc778 ELF-32\uc640 \ub3d9\uc77c\ud558\uac8c \ub418\ub3c4\ub85d \ud558\uac70\ub098 objcopy\uc758 \uacb0\uacfc \ubb3c\uc774 main.o\uc640 \ub3d9\uc77c\ud55c ELF-64\uac00 \ub418\ub3c4\ub85d \ud574\uc57c\ud55c\ub2e4.<\/p>\n<p>\uccab\ubc88\uc9f8 \ubc29\ubc95 &#8211; ELF-32 format\uc73c\ub85c object\ub97c compile<br \/>\ngcc\uc5d0 -m32 option\uc744 \ucd94\uac00\ud558\uba74 ELF32\ub85c compile\ub41c object file\uc744 \uc5bb\uc744 \uc218 \uc788\ub2e4. \uc774\uac83\uc744 objcopy\uc758 \uacb0\uacfc \ubb3c\uacfc link\ud55c\ub2e4.<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$&gt; objcopy -I binary -O elf32-i386 -B i386 binary.bmp binary.o\n$&gt; gcc -m32 -c main.c\n$&gt; gcc -m32 -o program main.o binary.o<\/pre>\n<p>\ub450\ubc88\uc9f8 \ubc29\ubc95 &#8211; ELF-64 format\uc73c\ub85c binary\ub97c \uc0dd\uc131<br \/>\nobjcopy\uac00 ELF64\ub97c \uc0dd\uc131\ud558\ub3c4\ub85d \ud558\uba74 gcc\ub85c compile\ud55c \ub2e4\ub978 object file\ub4e4\uacfc link\ud560 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$&gt; objcopy -I binary -O elf64-x86-64 -B i386 binary.bmp binary.o\n$&gt; gcc -c main.c\n$&gt; gcc -o program main.o binary.o<\/pre>\n<p>&nbsp;<\/p>\n<p>* objcopy\ub85c \uc0dd\uc131\ub41c ELF object\uc5d0\uc11c \ub2f4\uace0 \uc788\ub294 symbol\uc758 \ubaa9\ub85d\uc740 nm \uba85\ub839\uc5b4\ub098 readelf -s option\uc73c\ub85c \ubcfc \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">$&gt; nm binary.o\n00000000002fd036 D _binary_binary_bmp_end\n00000000002fd036 A _binary_binary_bmp_size\n0000000000000000 D _binary_binary_bmp_start\n\n$&gt;readelf -s binary.o\nSymbol table '.symtab' contains 5 entries:\n   Num:    Value          Size Type    Bind   Vis      Ndx Name\n     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND \n     1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 \n     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _binary_binary_bmp_start\n     3: 00000000002fd036     0 NOTYPE  GLOBAL DEFAULT    1 _binary_binary_bmp_end\n     4: 00000000002fd036     0 NOTYPE  GLOBAL DEFAULT  ABS _binary_binary_bmp_size<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;Binary Hacks&#8217;\uc758 hack #11\uc5d0\ub294 objcopy\ub97c \uc774\uc6a9\ud574\uc11c \uc2e4\ud589\ud30c\uc77c\uc5d0 binary\ub97c \ucd94\uac00\ud558\ub294 \ubc29\ubc95\uc774 \ub098\uc628\ub2e4. \uc774\uac83\uc744 \ub530\ub77c 64 bits machine\uc5d0\uc11c build\ud558\uba74 i386:x86-64 \ucd9c\ub825\ubb3c\uacfc i386 \ucd9c\ub825\ubb3c\uc774 incompatible \ud574\uc11c link\ud560 \uc218 \uc5c6\ub2e4\ub294 \uc624\ub958\uac00 \ubc1c\uc0dd\ud55c\ub2e4. $&gt; objcopy -I binary -O elf32-i386 -B i386 binary.bmp binary.o $&gt; gcc -c main.c $&gt; gcc -o program main.o binary.o \/usr\/bin\/ld: i386 architecture of input file &#8216;binary.o&#8217; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[5],"tags":[21,40,89],"class_list":["post-538","post","type-post","status-publish","format-standard","hentry","category-programming","tag-binaryhack","tag-elf","tag-objcopy"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":444,"url":"https:\/\/litcoder.com\/?p=444","url_meta":{"origin":538,"position":0},"title":"[\ucc45] Binary Hacks","author":"litcoder","date":"2012\ub144 12\uc6d4 31\uc77c","format":false,"excerpt":"\uc11c\uc810\uc5d0\uc11c \ubc31\uc218\uc9d3 \ud558\ub2e4\uac00 \ub09a\uc544\uc628 \ucc45\uc778\ub370 \uba70\uce60 \uc77d\uc5b4\ubcf4\ub2c8 \uc880 \uc5b4\ub835\uc9c0\ub9cc \uc88b\uc740 \ub0b4\uc6a9\uc774 \ub9ce\uc544\uc694. \uc624\ub77c\uc77c\ub9ac \ucc45\uc740 \ubcf4\ud1b5 \ud55c\ube5b \ubbf8\ub514\uc5b4\uc5d0\uc11c \ubc88\uc5ed \ud558\ub358\ub370 \uc774 \ucc45\uc758 \ucd9c\ud310\uc0ac \uc774\ub984\uc740 \uc880 \uc0dd\uc18c \ud569\ub2c8\ub2e4.'Hack'\uc5d0\uc11c \uc5f0\uc0c1\ub418\ub294 \uc5b4\ub450\uc6b4 \uc774\ubbf8\uc9c0\uc5d0\ub2e4 'cracking'\uc744 \uc5f0\uc0c1 \uc2dc\ud0a4\ub294 \uc6b0\ud568\ub9c8 \uadf8\ub9bc\uc5d0 '\ud574\ucee4\uac00 \uc804\uc218 \ud558\ub294'\uc774\ub77c\ub294 \ubd80\uc81c \ub355\uc778\uc9c0 \uc774 \ucc45\uc740 \ubcf4\uc548 section\uc5d0 \uc9c4\uc5f4\ub418\uc5b4 \uc788\uc5c8\uc2b5\ub2c8\ub2e4. (\uc77c\ubcf8\uc5b4 \ud310\uc740 \ubc14\ub451\ud310 \uadf8\ub9bc\uc774 \uc788\ub354\uad70\uc694)\ud558\uc9c0\ub9cc\u2026","rel":"","context":"&quot;\uc7a1\uae30&quot;\uc5d0\uc11c","block_context":{"text":"\uc7a1\uae30","link":"https:\/\/litcoder.com\/?cat=8"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/litcoder.com\/wp-content\/uploads\/2012\/12\/9788990758743_binary_hacks-e1609318261787.gif?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3208,"url":"https:\/\/litcoder.com\/?p=3208","url_meta":{"origin":538,"position":1},"title":"C++ template \uc120\uc5b8\uacfc \uad6c\ud604\uc744 \uc11c\ub85c \ub2e4\ub978 \ud30c\uc77c\uc5d0 \ub098\ub20c \uc218 \uc5c6\ub2e4","author":"litcoder","date":"2023\ub144 3\uc6d4 6\uc77c","format":false,"excerpt":"\ucee4\uc2a4\ud140 Queue \ud074\ub798\uc2a4\ub97c \uc791\uc131\ud558\ub294\ub370 queue\uc758 item\uc740 \ucd94\ud6c4\uc5d0 \ubcc0\uacbd \ub420 \uc218 \uc788\uc73c\ubbc0\ub85c \ud15c\ud50c\ub9bf\uc73c\ub85c \uc791\uc131\ud558\uace0\uc790 \ud55c\ub2e4. Queue class\ub97c header\uc5d0 \uc815\uc758\ud558\uace0 \uad6c\ud604\uc744 cpp \ud30c\uc77c\uc5d0 \uc791\uc131\ud574 \uc900\ub2e4\uc74c main \ud568\uc218\uc5d0\uc11c \ub2e4\uc74c\uacfc \uac19\uc774 queue\ub97c \uc0dd\uc131\ud558\uace0 \ucef4\ud30c\uc77c\uc744 \uc2dc\ub3c4\ud55c\ub2e4. \ub2e4\uc74c\uc740 \ud574\ub2f9 template\uc744 \uc0ac\uc6a9\ud558\ub294 caller(main \ud568\uc218)\uc774\ub2e4. \/\/ \/\/ C++ template instantiation test. \/\/ \/\/ - litcoder #include <iostream> #include\u2026","rel":"","context":"&quot;Programming&quot;\uc5d0\uc11c","block_context":{"text":"Programming","link":"https:\/\/litcoder.com\/?cat=5"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":466,"url":"https:\/\/litcoder.com\/?p=466","url_meta":{"origin":538,"position":2},"title":"Android NDK build architecture \ubcc0\uacbd\ud558\uae30","author":"litcoder","date":"2013\ub144 1\uc6d4 17\uc77c","format":false,"excerpt":"\uc544\ubb34 \uc124\uc815 \uc5c6\uc774 ndk\ub97c build \ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 arm\uc6a9 library\uac00 \ub9cc\ub4e4\uc5b4\uc9c4\ub2e4. $ <NDK_PATH>\/ndk-build Gdbserver : [arm-linux-androideabi-4.6] libs\/armeabi\/gdbserver Gdbsetup : libs\/armeabi\/gdb.setup Compile thumb : hello-jni <= hello-jni.c SharedLibrary : libhello-jni.so Install : libhello-jni.so => libs\/armeabi\/libhello-jni.so $ file obj\/local\/armeabi\/libhello-jni.so obj\/local\/armeabi\/libhello-jni.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not\u2026","rel":"","context":"&quot;Android&quot;\uc5d0\uc11c","block_context":{"text":"Android","link":"https:\/\/litcoder.com\/?cat=2"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":454,"url":"https:\/\/litcoder.com\/?p=454","url_meta":{"origin":538,"position":3},"title":"cannot open shared object file: No such file or directory","author":"litcoder","date":"2013\ub144 1\uc6d4 9\uc77c","format":false,"excerpt":"64bit ubuntu\uc5d0\uc11c locate \ub4f1\uc758 \uba85\ub839\uc5b4\ub85c \ucc3e\uc544\ubcf4\uba74 library\uac00 \uc788\uc73c\ub098 \uc2e4\uc81c\ub85c\ub294 \uc218\ud589\ud560 \ub54c \ucc3e\uc744 \uc218 \uc5c6\ub2e4\ub294 \uc624\ub958\ub97c \ub0b4\uba74\uc11c \uc8fd\ub294 \uacbd\uc6b0\uac00 \uc788\ub2e4. \uc544\ub798\ub294 android build \uc911\uc5d0 \uc218\ud589\ub418\ub294 \uc5b4\ub5a4 \uc2e4\ud589 \ud30c\uc77c\uc774 libQtGui.so.4\ub97c \ucc3e\uc9c0 \ubabb\ud574 \uc885\ub8cc\ud55c \ube4c\ub4dc \ub85c\uadf8\uc774\ub2e4. ... .\/bin\/EXE_FILE: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or\u2026","rel":"","context":"&quot;Linux&quot;\uc5d0\uc11c","block_context":{"text":"Linux","link":"https:\/\/litcoder.com\/?cat=4"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3957,"url":"https:\/\/litcoder.com\/?p=3957","url_meta":{"origin":538,"position":4},"title":"Raspberry Pi\uc6a9 Qt5 Cross Compile","author":"litcoder","date":"2025\ub144 12\uc6d4 24\uc77c","format":false,"excerpt":"\uc774 \ud3ec\uc2a4\ud305\uc740 Qt5 5.15.11\uc744 RPi5\uc6a9\uc73c\ub85c \ud06c\ub85c\uc2a4 \ucef4\ud30c\uc77c \ud558\ub294 \uacfc\uc815\uc744 \uc815\ub9ac\ud55c \uac83\uc774\ub2e4. Build host\ub294 Ubuntu 24.04\uc774\ub2e4. Overview 2025\ub144 12\uc6d4 \ud604\uc7ac, Qt5\uac00 RPi\uc6a9 deb package \uc0dd\uc131\uc744 \uc9c1\uc811 \uc9c0\uc6d0\ud558\uc9c0\ub294 \uc54a\uae30 \ub54c\ubb38\uc5d0 \ub2e4\uc18c \ubcf5\uc7a1\ud558\uace0 \ubc88\uac70\ub86d\uae34 \ud558\uc9c0\ub9cc, target\uc778 Raspberry Pi OS\uc758 image \ud30c\uc77c\uc744 \ube4c\ub4dc \ud638\uc2a4\ud2b8 \uba38\uc2e0\uc5d0 loop device\ub85c \ub9c8\uc6b4\ud2b8 \uc2dc\ucf1c\uc11c \ud06c\ub85c\uc2a4 \ucef4\ud30c\uc77c\uc744 \uc218\ud589\ud558\uace0 \uadf8 \uacb0\uacfc\ub97c\u2026","rel":"","context":"&quot;Linux&quot;\uc5d0\uc11c","block_context":{"text":"Linux","link":"https:\/\/litcoder.com\/?cat=4"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/litcoder.com\/wp-content\/uploads\/2025\/12\/qt5_raspios_mount.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/litcoder.com\/wp-content\/uploads\/2025\/12\/qt5_raspios_mount.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/litcoder.com\/wp-content\/uploads\/2025\/12\/qt5_raspios_mount.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/litcoder.com\/wp-content\/uploads\/2025\/12\/qt5_raspios_mount.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/litcoder.com\/wp-content\/uploads\/2025\/12\/qt5_raspios_mount.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":2627,"url":"https:\/\/litcoder.com\/?p=2627","url_meta":{"origin":538,"position":5},"title":"GCC\uc5d0\uc11c integer arithmetic overflow \ubc29\uc9c0 \ub300\ucc45","author":"litcoder","date":"2020\ub144 11\uc6d4 25\uc77c","format":false,"excerpt":"Arithmetic overflow\ub294 \ubd80\ud638 \uc788\ub294 \ubcc0\uc218(signed variable)\uac00 \ud45c\uc2dc \ud560 \uc218 \uc788\ub294 \ucd5c\ub313\uac12 \/ \ucd5c\uc19f\uac12\uc744 \ub118\uc5b4 \uc130\uc744 \ub54c \ubd80\ud638\uac00 \ubc14\ub00c\uba74\uc11c \uc6d0\ud558\uc9c0 \uc54a\ub294 \uacb0\uacfc\uac00 \ub098\ud0c0\ub098\ub294 \uacbd\uc6b0\ub97c \ub9d0\ud55c\ub2e4. #include <iostream> #include <climits> using namespace std; int main(void) { int r = 0; int op = INT_MAX; cout << op << \" + 1 =\u2026","rel":"","context":"&quot;Linux&quot;\uc5d0\uc11c","block_context":{"text":"Linux","link":"https:\/\/litcoder.com\/?cat=4"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=538"}],"version-history":[{"count":0,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions"}],"wp:attachment":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}