제로 시작 OS 자작 입문 5장 osbookday05c objcopy 옵션 노트

집행할 명령은 여기 있습니다.p. 127
objcopy -I binary -O elf64-x86-64 -B i386:x86-64 hankaku.bin hankaku.o
의 의미는 다음과 같다.
-I bfdname
--input-target=bfdname
   Consider the source file's object format to be bfdname, rather than attempting to deduce it.

-O bfdname
--output-target=bfdname
   Write the output file using the object format bfdname.

-B bfdarch
--binary-architecture=bfdarch
   Useful when transforming a architecture-less input file into an object file.  In this case the output architecture can be set to bfdarch.
   This option will be ignored if the input file has a known bfdarch.  You can access this binary data inside a program by referencing the
   special symbols that are created by the conversion process.  These symbols are called _binary_objfile_start, _binary_objfile_end and
   _binary_objfile_size.  e.g. you can transform a picture file into an object file and then access it in your code using these symbols.
p.126의
_binary에서 시작하는 세 변수는 objcopy 명령에 의해 결정되는 이름이기 때문에 자유롭게 이름을 붙일 수 없습니다.
-B의 설명입니다.
These symbols are called _binary_objfile_start, _binary_objfile_end and _binary_objfile_size

bfdname 소개


GNU BFD 라이브러리BFD 라이브러리 - 위키백과
objcopy는 GNU binutils에 포함되어 있으며 GNU binutils의 몇 가지 도구는 이 BFD 라이브러리를 사용하는 것 같습니다.
지정할 수 있는 bfdname은objudmp의 출력을 통해 확인할 수 있습니다GNU Development toolkit.
예를 들면 이렇다.줄을 적당히 바꾸다.-O-I에 지정된 대상 이름입니다.-B에서 지정한 것은 구조 이름입니다.
$ objdump --hep

略

objdump: サポートされているターゲット:
  elf64-x86-64       # -O elf64-x86-64 に指定している
  elf32-i386
  elf32-iamcu
  elf32-x86-64
  pei-i386
  pei-x86-64
  elf64-l1om
  elf64-k1om
  elf64-little
  elf64-big
  elf32-little
  elf32-big
  pe-x86-64
  pe-bigobj-x86-64
  pe-i386
  srec
  symbolsrec
  verilog
  tekhex
  binary            # -I binary に指定している
  ihex
  plugin

objdump: サポートされているアーキテクチャ:
  i386
  i386:x86-64       # -B i386:x86-64 に指定している
  i386:x64-32
  i8086
  i386:intel
  i386:x86-64:intel
  i386:x64-32:intel
  i386:nacl
  i386:x86-64:nacl
  i386:x64-32:nacl
  iamcu
  iamcu:intel
  l1om
  l1om:intel
  k1om
  k1om:intel
도objudp-i에 나타난다.
$ objdump -i
BFD ヘッダファイルバージョン (GNU Binutils for Ubuntu) 2.34
elf64-x86-64
 (header リトルエンディアン, data リトルエンディアン)
  i386

略

binary
 (header エンディアン不明, data エンディアン不明)
  i386
  l1om
  k1om
  iamcu

좋은 웹페이지 즐겨찾기