mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 02:24:17 +08:00
* som.c (som_begin_writing): New approach at dealing with holes
in executables left by the HP linker. Does not rely on subspace alignments as subspaces are *NOT* guaranteed to be properly aligned in an executable (can you believe that!).
This commit is contained in:
@ -155,6 +155,13 @@ Mon Mar 28 12:53:27 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
|||||||
* aoutx.h (translate_from_native_sym_flags): Set SEC_RELOC flag
|
* aoutx.h (translate_from_native_sym_flags): Set SEC_RELOC flag
|
||||||
for generated constructor section.
|
for generated constructor section.
|
||||||
|
|
||||||
|
Sun Mar 27 16:25:22 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
|
||||||
|
|
||||||
|
* som.c (som_begin_writing): New approach at dealing with holes
|
||||||
|
in executables left by the HP linker. Does not rely on subspace
|
||||||
|
alignments as subspaces are *NOT* guaranteed to be properly
|
||||||
|
aligned in an executable (can you believe that!).
|
||||||
|
|
||||||
Sat Mar 26 10:25:43 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
|
Sat Mar 26 10:25:43 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
|
||||||
|
|
||||||
* som.c (som_get_section_contents): New function. Do not try
|
* som.c (som_get_section_contents): New function. Do not try
|
||||||
|
45
bfd/som.c
45
bfd/som.c
@ -2922,6 +2922,7 @@ som_begin_writing (abfd)
|
|||||||
{
|
{
|
||||||
asection *subsection;
|
asection *subsection;
|
||||||
int first_subspace;
|
int first_subspace;
|
||||||
|
unsigned int subspace_offset = 0;
|
||||||
|
|
||||||
/* Find a space. */
|
/* Find a space. */
|
||||||
while (!som_is_space (section))
|
while (!som_is_space (section))
|
||||||
@ -2970,31 +2971,38 @@ som_begin_writing (abfd)
|
|||||||
exec_header.exec_dfile = current_offset;
|
exec_header.exec_dfile = current_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keep track of exactly where we are within a particular
|
||||||
|
space. This is necessary as the braindamaged HPUX
|
||||||
|
loader will create holes between subspaces *and*
|
||||||
|
subspace alignments are *NOT* preserved. What a crock. */
|
||||||
|
subspace_offset = subsection->vma;
|
||||||
|
|
||||||
/* Only do this for the first subspace within each space. */
|
/* Only do this for the first subspace within each space. */
|
||||||
first_subspace = 0;
|
first_subspace = 0;
|
||||||
}
|
}
|
||||||
else if (abfd->flags & EXEC_P)
|
else if (abfd->flags & EXEC_P)
|
||||||
{
|
{
|
||||||
/* Have to keep proper alignments for the subspaces
|
/* The braindamaged HPUX loader may have created a hole
|
||||||
in executables too! */
|
between two subspaces. It is *not* sufficient to use
|
||||||
|
the alignment specifications within the subspaces to
|
||||||
|
account for these holes -- I've run into at least one
|
||||||
|
case where the loader left one code subspace unaligned
|
||||||
|
in a final executable.
|
||||||
|
|
||||||
|
To combat this we keep a current offset within each space,
|
||||||
|
and use the subspace vma fields to detect and preserve
|
||||||
|
holes. What a crock!
|
||||||
|
|
||||||
|
ps. This is not necessary for unloadable space/subspaces. */
|
||||||
|
current_offset += subsection->vma - subspace_offset;
|
||||||
if (subsection->flags & SEC_CODE)
|
if (subsection->flags & SEC_CODE)
|
||||||
{
|
exec_header.exec_tsize += subsection->vma - subspace_offset;
|
||||||
unsigned tmp = exec_header.exec_tsize;
|
|
||||||
|
|
||||||
tmp = SOM_ALIGN (tmp, 1 << subsection->alignment_power);
|
|
||||||
current_offset += (tmp - exec_header.exec_tsize);
|
|
||||||
exec_header.exec_tsize = tmp;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
exec_header.exec_dsize += subsection->vma - subspace_offset;
|
||||||
unsigned tmp = exec_header.exec_dsize;
|
subspace_offset += subsection->vma - subspace_offset;
|
||||||
|
|
||||||
tmp = SOM_ALIGN (tmp, 1 << subsection->alignment_power);
|
|
||||||
current_offset += (tmp - exec_header.exec_dsize);
|
|
||||||
exec_header.exec_dsize = tmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
subsection->target_index = total_subspaces++;
|
subsection->target_index = total_subspaces++;
|
||||||
/* This is real data to be loaded from the file. */
|
/* This is real data to be loaded from the file. */
|
||||||
if (subsection->flags & SEC_LOAD)
|
if (subsection->flags & SEC_LOAD)
|
||||||
@ -3008,8 +3016,9 @@ som_begin_writing (abfd)
|
|||||||
exec_header.exec_dsize += subsection->_cooked_size;
|
exec_header.exec_dsize += subsection->_cooked_size;
|
||||||
som_section_data (subsection)->subspace_dict->file_loc_init_value
|
som_section_data (subsection)->subspace_dict->file_loc_init_value
|
||||||
= current_offset;
|
= current_offset;
|
||||||
section->filepos = current_offset;
|
subsection->filepos = current_offset;
|
||||||
current_offset += bfd_section_size (abfd, subsection);
|
current_offset += bfd_section_size (abfd, subsection);
|
||||||
|
subspace_offset += bfd_section_size (abfd, subsection);
|
||||||
}
|
}
|
||||||
/* Looks like uninitialized data. */
|
/* Looks like uninitialized data. */
|
||||||
else
|
else
|
||||||
@ -3065,7 +3074,7 @@ som_begin_writing (abfd)
|
|||||||
{
|
{
|
||||||
som_section_data (subsection)->subspace_dict->file_loc_init_value
|
som_section_data (subsection)->subspace_dict->file_loc_init_value
|
||||||
= current_offset;
|
= current_offset;
|
||||||
section->filepos = current_offset;
|
subsection->filepos = current_offset;
|
||||||
current_offset += bfd_section_size (abfd, subsection);
|
current_offset += bfd_section_size (abfd, subsection);
|
||||||
}
|
}
|
||||||
/* Looks like uninitialized data. */
|
/* Looks like uninitialized data. */
|
||||||
|
Reference in New Issue
Block a user