symbol = part->reloc_arr[i].symbol;
if (symbol_is_undefined (symbol)) {
+
symbol = symbol_find (symbol->name);
+
+ if (strcmp (symbol->name, "__edata") == 0 || strcmp (symbol->name, "__end") == 0) {
+ continue;
+ }
+
}
integer_to_array (part->rva - part->section->rva + part->reloc_arr[i].offset, rel.r_address, 4);
collapse_subsections ();
calculate_section_sizes_and_rvas ();
- if (!(symbol = symbol_find ("__edata")) || symbol_is_undefined (symbol)) {
+ if ((symbol = symbol_find ("__edata")) && symbol_is_undefined (symbol)) {
if ((section = section_find (".text"))) {
- value += (/*section->rva + */section->total_size);
- /*value -= state->size_of_headers;*/
+ if (state->format == LD_FORMAT_I386_PE) {
+ value += pe_align_to_file_alignment (section->total_size);
+ } else {
+ value += section->total_size;
+ }
}
symbol->value = value / 16;
symbol_record_external_symbol (symbol);
- value %= 16;
}
- if (!(symbol = symbol_find ("__end")) || symbol_is_undefined (symbol)) {
+ value %= 16;
+
+ if ((symbol = symbol_find ("__end")) && symbol_is_undefined (symbol)) {
if ((section = section_find (".data"))) {
- value += section->total_size;
+
+ if (state->format == LD_FORMAT_I386_PE) {
+ value += pe_align_to_file_alignment (section->total_size);
+ } else {
+ value += section->total_size;
+ }
+
}
if ((section = section_find (".bss"))) {
- value += section->total_size;
+
+ if (state->format == LD_FORMAT_I386_PE) {
+ value += pe_align_to_file_alignment (section->total_size);
+ } else {
+ value += section->total_size;
+ }
+
}
of = object_file_make (FAKE_LD_FILENAME, 1);
unsigned long pe_get_first_section_rva (void) {
return ALIGN (state->size_of_headers, section_alignment);
}
+
+unsigned long pe_align_to_file_alignment (unsigned long value) {
+ return ALIGN (value, file_alignment);
+}
void pe_before_link (void);
void pe_print_help (void);
+unsigned long pe_align_to_file_alignment (unsigned long value);
unsigned long pe_get_first_section_rva (void);
void pe_write (const char *filename);