nasm -hf
->파일 포맷 확인하기
unname -a
-> linux OS version 확인. x86_64는 64bit 임 x686이 32bit임
cat /proc/cpuinfo
-> 리눅스 cpu 확인
gcc -v -o first.o
-> 오브젝트 파일 타겟이 어떻게 되는지 확인 등
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: .....
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
rpm -qa | grep gblic
-> red hat packgage 검색 -q, a는 모두? 그 중 glibc가 있는지. 있으면 x86_64 말고 i686도 있는지
glibc-devel-2.12-1.132.el6.x86_64
glibc-headers-2.12-1.132.el6.x86_64
glibc-common-2.12-1.132.el6.x86_64
glibc-2.12-1.132.el6.x86_64
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
-> ubuntu : suto apt-get install gcc-multilib 설치
-> redhat : yum install glibc.i686 ? 이건 안되는 듯 yum install libgcc.i686 이건 되는듯
최종 컴파일
nasm -f elf first.asm //32bit o
nasm -f elf -d ELF_TYPE asm_io.asm
gcc -m32 -o first first.o asm_io.o -nostartfiles // -nostartfiles는 안해도 될듯?
140502--------------------
이대로 해도 컴파일은 되는데 세그먼테이션 에러남
.asm 파일에서 기본 _asm_main같이 된 라벨을 -> main으로 변경
[source]
global main
main:
[complie]
nasm -f elf first.asm
nasm -f elf -d ELF_TYPE asm_io.asm
gcc -m32 -o first first.o asm_io.o
'컴퓨터 과학 & 영상처리 관련 > Assembly (시스템 소프트웨어)' 카테고리의 다른 글
리눅스 어셈블리 즐겨찾기 (0) | 2014.04.06 |
---|---|
linux printf 이용한 NASM 예제 (0) | 2014.04.06 |
first.asm (0) | 2014.04.02 |
NASM system call int 명령어 (0) | 2014.03.29 |
NASM db dw dd dq 의미 (0) | 2014.03.28 |