mirror of
https://frontier.innolan.net/github/amigaos-binutils.git
synced 2025-11-21 18:56:28 +00:00
Factor out common code for processing a.out and hunk relocations.
* bfd/amigaoslink.c (amiga_update_target_section): New function, broken out of amiga_perform_reloc. (amiga_perform_reloc): Use it. (aout_update_target_section): New function, broken out of aout_perform_reloc. (aout_perform_reloc): Use it.
This commit is contained in:
@ -112,8 +112,10 @@ aout_amiga_final_link PARAMS ((bfd *, struct bfd_link_info *));
|
|||||||
|
|
||||||
static bfd_reloc_status_type
|
static bfd_reloc_status_type
|
||||||
my_add_to PARAMS ((arelent *, PTR, int, int));
|
my_add_to PARAMS ((arelent *, PTR, int, int));
|
||||||
|
static void amiga_update_target_section PARAMS ((sec_ptr));
|
||||||
static bfd_reloc_status_type
|
static bfd_reloc_status_type
|
||||||
amiga_perform_reloc PARAMS ((bfd *, arelent *, PTR, sec_ptr, bfd *, char **));
|
amiga_perform_reloc PARAMS ((bfd *, arelent *, PTR, sec_ptr, bfd *, char **));
|
||||||
|
static void aout_update_target_section PARAMS ((sec_ptr));
|
||||||
static bfd_reloc_status_type
|
static bfd_reloc_status_type
|
||||||
aout_perform_reloc PARAMS ((bfd *, arelent *, PTR, sec_ptr, bfd *, char **));
|
aout_perform_reloc PARAMS ((bfd *, arelent *, PTR, sec_ptr, bfd *, char **));
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
@ -344,6 +346,34 @@ my_add_to (r, data, add, flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* For base-relative linking place .bss symbols in the .data section. */
|
||||||
|
static void
|
||||||
|
amiga_update_target_section (target_section)
|
||||||
|
sec_ptr target_section;
|
||||||
|
{
|
||||||
|
/* If target->out is .bss, add the value of the .data section to
|
||||||
|
sym->value and set new output_section */
|
||||||
|
/* If we access a symbol in the .bss section, we have to convert
|
||||||
|
this to an access to .data section */
|
||||||
|
/* This is done through a change to the output section of
|
||||||
|
the symbol.. */
|
||||||
|
if (!strcmp(target_section->output_section->name,".bss"))
|
||||||
|
{
|
||||||
|
/* get value for .data section */
|
||||||
|
bfd *ibfd;
|
||||||
|
sec_ptr s;
|
||||||
|
|
||||||
|
ibfd=target_section->output_section->owner;
|
||||||
|
for (s=ibfd->sections;s!=NULL;s=s->next)
|
||||||
|
if (!strcmp(s->name,".data"))
|
||||||
|
{
|
||||||
|
target_section->output_offset=s->_raw_size;
|
||||||
|
target_section->output_section=s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Perform an Amiga relocation */
|
/* Perform an Amiga relocation */
|
||||||
static bfd_reloc_status_type
|
static bfd_reloc_status_type
|
||||||
amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
||||||
@ -406,25 +436,8 @@ amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If we access a symbol in the .bss section, we have to convert
|
if (amiga_base_relative)
|
||||||
this to an access to .data section */
|
amiga_update_target_section (target_section);
|
||||||
/* This is done through a change to the output section of
|
|
||||||
the symbol.. */
|
|
||||||
if (amiga_base_relative
|
|
||||||
&& !strcmp(target_section->output_section->name,".bss"))
|
|
||||||
{
|
|
||||||
/* get value for .data section */
|
|
||||||
bfd *ibfd;
|
|
||||||
sec_ptr s;
|
|
||||||
|
|
||||||
ibfd=target_section->output_section->owner;
|
|
||||||
for (s=ibfd->sections;s!=NULL;s=s->next)
|
|
||||||
if (!strcmp(s->name,".data"))
|
|
||||||
{
|
|
||||||
target_section->output_offset=s->_raw_size;
|
|
||||||
target_section->output_section=s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
relocation=0;
|
relocation=0;
|
||||||
copy=TRUE;
|
copy=TRUE;
|
||||||
}
|
}
|
||||||
@ -475,21 +488,7 @@ amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If target->out is .bss, add the value of the .data section to
|
amiga_update_target_section (target_section);
|
||||||
sym->value and set new output_section */
|
|
||||||
if (!strcmp(target_section->output_section->name,".bss"))
|
|
||||||
{
|
|
||||||
bfd *ibfd;
|
|
||||||
sec_ptr s;
|
|
||||||
|
|
||||||
ibfd=target_section->output_section->owner;
|
|
||||||
for (s=ibfd->sections;s!=NULL;s=s->next)
|
|
||||||
if (!strcmp(s->name,".data"))
|
|
||||||
{
|
|
||||||
target_section->output_offset=s->_raw_size;
|
|
||||||
target_section->output_section=s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
relocation = sym->value + target_section->output_offset
|
relocation = sym->value + target_section->output_offset
|
||||||
- (AMIGA_DATA(target_section->output_section->owner))->a4init
|
- (AMIGA_DATA(target_section->output_section->owner))->a4init
|
||||||
@ -521,6 +520,34 @@ amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* For base-relative linking place .bss symbols in the .data section. */
|
||||||
|
static void
|
||||||
|
aout_update_target_section (target_section)
|
||||||
|
sec_ptr target_section;
|
||||||
|
{
|
||||||
|
/* If target->out is .bss, add the value of the .data section to
|
||||||
|
sym->value and set new output_section */
|
||||||
|
/* If we access a symbol in the .bss section, we have to convert
|
||||||
|
this to an access to .data section */
|
||||||
|
/* This is done through a change to the output section of
|
||||||
|
the symbol.. */
|
||||||
|
if (!strcmp(target_section->output_section->name,".bss"))
|
||||||
|
{
|
||||||
|
/* get value for .data section */
|
||||||
|
bfd *ibfd;
|
||||||
|
sec_ptr s;
|
||||||
|
|
||||||
|
ibfd=target_section->output_section->owner;
|
||||||
|
for (s=ibfd->sections;s!=NULL;s=s->next)
|
||||||
|
if (!strcmp(s->name,".data"))
|
||||||
|
{
|
||||||
|
target_section->output_offset+=s->_raw_size;
|
||||||
|
target_section->output_section=s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Perform an a.out relocation */
|
/* Perform an a.out relocation */
|
||||||
static bfd_reloc_status_type
|
static bfd_reloc_status_type
|
||||||
aout_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
aout_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
||||||
@ -611,25 +638,8 @@ aout_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If we access a symbol in the .bss section, we have to convert
|
if (amiga_base_relative)
|
||||||
this to an access to .data section */
|
aout_update_target_section (target_section);
|
||||||
/* This is done through a change to the output section of
|
|
||||||
the symbol.. */
|
|
||||||
if (amiga_base_relative
|
|
||||||
&& !strcmp(target_section->output_section->name,".bss"))
|
|
||||||
{
|
|
||||||
/* get value for .data section */
|
|
||||||
bfd *ibfd;
|
|
||||||
sec_ptr s;
|
|
||||||
|
|
||||||
ibfd=target_section->output_section->owner;
|
|
||||||
for (s=ibfd->sections;s!=NULL;s=s->next)
|
|
||||||
if (!strcmp(s->name,".data"))
|
|
||||||
{
|
|
||||||
target_section->output_offset+=s->_raw_size;
|
|
||||||
target_section->output_section=s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
relocation=0;
|
relocation=0;
|
||||||
copy=TRUE;
|
copy=TRUE;
|
||||||
}
|
}
|
||||||
@ -684,21 +694,7 @@ aout_perform_reloc (abfd, r, data, sec, obfd, error_message)
|
|||||||
}
|
}
|
||||||
else /* Target section and sec need not be the same.. */
|
else /* Target section and sec need not be the same.. */
|
||||||
{
|
{
|
||||||
/* If target->out is .bss, add the value of the .data section to
|
aout_update_target_section (target_section);
|
||||||
sym->value and set new output_section */
|
|
||||||
if (!strcmp(target_section->output_section->name,".bss"))
|
|
||||||
{
|
|
||||||
bfd *ibfd;
|
|
||||||
sec_ptr s;
|
|
||||||
|
|
||||||
ibfd=target_section->output_section->owner;
|
|
||||||
for (s=ibfd->sections;s!=NULL;s=s->next)
|
|
||||||
if (!strcmp(s->name,".data"))
|
|
||||||
{
|
|
||||||
target_section->output_offset+=s->_raw_size;
|
|
||||||
target_section->output_section=s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
relocation = sym->value + target_section->output_offset
|
relocation = sym->value + target_section->output_offset
|
||||||
- (AMIGA_DATA(target_section->output_section->owner))->a4init;
|
- (AMIGA_DATA(target_section->output_section->owner))->a4init;
|
||||||
|
|||||||
Reference in New Issue
Block a user