2 #define HAVE_SECTION_RELOC
4 static ElfW_Rel
*qrel
; /* ptr to next reloc entry reused */
6 void relocate_init(Section
*sr
)
8 qrel
= (ElfW_Rel
*) sr
->data
;
11 void relocate(TCCState
*s1
, ElfW_Rel
*rel
, int type
, char *ptr
, addr_t addr
, addr_t val
)
13 int sym_index
, esym_index
;
15 sym_index
= ELFW(R_SYM
)(rel
->r_info
);
19 if (s1
->output_type
== TCC_OUTPUT_DLL
) {
20 esym_index
= s1
->symtab_to_dynsym
[sym_index
];
21 qrel
->r_offset
= rel
->r_offset
;
23 qrel
->r_info
= ELFW(R_INFO
)(esym_index
, R_386_32
);
27 qrel
->r_info
= ELFW(R_INFO
)(0, R_386_RELATIVE
);
34 if (s1
->output_type
== TCC_OUTPUT_DLL
) {
36 esym_index
= s1
->symtab_to_dynsym
[sym_index
];
38 qrel
->r_offset
= rel
->r_offset
;
39 qrel
->r_info
= ELFW(R_INFO
)(esym_index
, R_386_PC32
);
44 add32le(ptr
, val
- addr
);
47 add32le(ptr
, val
- addr
);
54 add32le(ptr
, s1
->got
->sh_addr
- addr
);
57 add32le(ptr
, val
- s1
->got
->sh_addr
);
61 /* we load the got offset */
62 add32le(ptr
, s1
->sym_attrs
[sym_index
].got_offset
);
65 if (s1
->output_format
!= TCC_OUTPUT_FORMAT_BINARY
) {
67 tcc_error("can only produce 16-bit binary files");
69 write16le(ptr
, read16le(ptr
) + val
);
72 if (s1
->output_format
!= TCC_OUTPUT_FORMAT_BINARY
)
74 write16le(ptr
, read16le(ptr
) + val
- addr
);
80 /* This reloction must copy initialized data from the library
81 to the program .bss segment. Currently made like for ARM
82 (to remove noise of defaukt case). Is this true?
86 fprintf(stderr
,"FIXME: handle reloc type %d at %x [%p] to %x\n",
87 type
, (unsigned)addr
, ptr
, (unsigned)val
);