This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
writing binary code
- To: binutils at sourceware dot cygnus dot com
- Subject: writing binary code
- From: Dmitry <diwil at eis dot ru>
- Date: Fri, 2 Nov 2001 11:46:15 +0300
- Organization: eis.ru
Fellows,
One more question.
For example, I've got an instruction
move.w symbol, &0x1234 ; move address of symbol to
; memory location 0x1234
which resides in memory as:
0x1234 <- 16 bit
symbol <- 16 bit
move.w <- 16 bit
Binary code should be:
memory: 4291 sLsH 3412
cmds: move.w symbol 0x1234
where
9142 is move.w binary code
sLsH is representation of the symbol's address after relocation.
1234 is known memory locateion
Can I do the following:
1: frag = frag_more(opcode->insn_size); /* instr size 6 bytes */
2: where = frag - frag_now->fr_literal;
3: bfd_putl16 ( (bfd_vma) opcode->binopbase, frag);
4: /* prepare symbol relocation */
5: parse_exp (symbol, &exp);
6: fix_new_exp (frag_now, where+2, 2, &exp, true, BFD_RELOC_MYCPU_16_PCREL);
7: /* put 0x1234 */
8: bfd_putl16 ( (bfd_vma)0x1234, frag+4);
Do I understand correct that I can issue bfd_putl16() at any time I want,
providind the fragment has been allocated and I put data within the fragment
boundaries?
Or I should issue a bfd_putl[XX] on whole instruction only?
Thanks in advance,
Dmitry.
*********************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys
(_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 314-8860, 5585314
*********************************************************************