summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-03-08 13:41:07 +1030
committerAlan Modra <amodra@gmail.com>2023-03-08 17:47:35 +1030
commit447d06696999be437b0e3c1a1f26e050ad91b952 (patch)
tree639774860ca159256cc6330613b84939abf31047 /bfd
parentc8e85484d8a0fe9f7b88e00a6b9ae63bcb53ba32 (diff)
downloadbinutils-gdb-447d06696999be437b0e3c1a1f26e050ad91b952.tar.gz
Tidy pe_ILF_build_a_bfd a little
* peicode.h (ILF section, pe_ILF_object_p): Correct comments and update the reference to Microsoft's docs. (pe_ILF_build_a_bfd): Move all symbol creation before flipping the bfd over to in-memory.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/peicode.h64
1 files changed, 31 insertions, 33 deletions
diff --git a/bfd/peicode.h b/bfd/peicode.h
index 43226caf00e..b7b4f4abbb9 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -401,11 +401,11 @@ pe_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
#ifdef COFF_IMAGE_WITH_PE
-/* Code to handle Microsoft's Image Library Format.
+/* Code to handle Microsoft's Import Library Format.
Also known as LINK6 format.
Documentation about this format can be found at:
- http://msdn.microsoft.com/library/specs/pecoff_section8.htm */
+ https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format */
/* The following constants specify the sizes of the various data
structures that we have to create in order to build a bfd describing
@@ -1074,6 +1074,32 @@ pe_ILF_build_a_bfd (bfd * abfd,
abort ();
}
+ /* Now create a symbol describing the imported value. */
+ switch (import_type)
+ {
+ case IMPORT_CODE:
+ pe_ILF_make_a_symbol (& vars, "", symbol_name, text,
+ BSF_NOT_AT_END | BSF_FUNCTION);
+
+ break;
+
+ case IMPORT_DATA:
+ /* Nothing to do here. */
+ break;
+
+ default:
+ /* XXX code not yet written. */
+ abort ();
+ }
+
+ /* Create an import symbol for the DLL, without the .dll suffix. */
+ ptr = (bfd_byte *) strrchr (source_dll, '.');
+ if (ptr)
+ * ptr = 0;
+ pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0);
+ if (ptr)
+ * ptr = '.';
+
/* Initialise the bfd. */
memset (& internal_f, 0, sizeof (internal_f));
@@ -1100,39 +1126,13 @@ pe_ILF_build_a_bfd (bfd * abfd,
bfd_cache_close (abfd);
abfd->iostream = (void *) vars.bim;
- abfd->flags |= BFD_IN_MEMORY /* | HAS_LOCALS */;
+ abfd->flags |= BFD_IN_MEMORY | HAS_SYMS;
abfd->iovec = &_bfd_memory_iovec;
abfd->where = 0;
abfd->origin = 0;
abfd->size = 0;
obj_sym_filepos (abfd) = 0;
- /* Now create a symbol describing the imported value. */
- switch (import_type)
- {
- case IMPORT_CODE:
- pe_ILF_make_a_symbol (& vars, "", symbol_name, text,
- BSF_NOT_AT_END | BSF_FUNCTION);
-
- break;
-
- case IMPORT_DATA:
- /* Nothing to do here. */
- break;
-
- default:
- /* XXX code not yet written. */
- abort ();
- }
-
- /* Create an import symbol for the DLL, without the .dll suffix. */
- ptr = (bfd_byte *) strrchr (source_dll, '.');
- if (ptr)
- * ptr = 0;
- pe_ILF_make_a_symbol (& vars, "__IMPORT_DESCRIPTOR_", source_dll, NULL, 0);
- if (ptr)
- * ptr = '.';
-
/* Point the bfd at the symbol table. */
obj_symbols (abfd) = vars.sym_cache;
abfd->symcount = vars.sym_index;
@@ -1149,8 +1149,6 @@ pe_ILF_build_a_bfd (bfd * abfd,
obj_coff_strings (abfd) = vars.string_table;
obj_coff_keep_strings (abfd) = true;
- abfd->flags |= HAS_SYMS;
-
return true;
error_return:
@@ -1159,7 +1157,7 @@ pe_ILF_build_a_bfd (bfd * abfd,
return false;
}
-/* We have detected a Image Library Format archive element.
+/* We have detected an Import Library Format archive element.
Decode the element and return the appropriate target. */
static bfd_cleanup
@@ -1176,7 +1174,7 @@ pe_ILF_object_p (bfd * abfd)
unsigned int magic;
/* Upon entry the first six bytes of the ILF header have
- already been read. Now read the rest of the header. */
+ already been read. Now read the rest of the header. */
if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14)
return NULL;