* [PATCH] ld: use definitions in generate_reloc rather than raw literals
@ 2022-05-02 13:04 Mark Harmstone
2022-05-18 14:54 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Mark Harmstone @ 2022-05-02 13:04 UTC (permalink / raw)
To: binutils; +Cc: Mark Harmstone
Constant names come from the "PE Format" specifications on the Microsoft
website.
---
include/coff/internal.h | 16 ++++++++++++++++
ld/pe-dll.c | 15 ++++++++-------
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/include/coff/internal.h b/include/coff/internal.h
index f12908b0f65..4d2046ee090 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -694,4 +694,20 @@ struct internal_reloc
unsigned long r_offset; /* Used by Alpha ECOFF, SPARC, others */
};
+#define IMAGE_REL_BASED_ABSOLUTE 0
+#define IMAGE_REL_BASED_HIGH 1
+#define IMAGE_REL_BASED_LOW 2
+#define IMAGE_REL_BASED_HIGHLOW 3
+#define IMAGE_REL_BASED_HIGHADJ 4
+#define IMAGE_REL_BASED_MIPS_JMPADDR 5
+#define IMAGE_REL_BASED_ARM_MOV32 5
+#define IMAGE_REL_BASED_RISCV_HIGH20 5
+#define IMAGE_REL_BASED_THUMB_MOV32 7
+#define IMAGE_REL_BASED_RISCV_LOW12I 7
+#define IMAGE_REL_BASED_RISCV_LOW12S 8
+#define IMAGE_REL_BASED_LOONGARCH32_MARK_LA 8
+#define IMAGE_REL_BASED_LOONGARCH64_MARK_LA 8
+#define IMAGE_REL_BASED_MIPS_JMPADDR16 9
+#define IMAGE_REL_BASED_DIR64 10
+
#endif /* GNU_COFF_INTERNAL_H */
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index c5ffd9ef032..81e52905c69 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -1654,20 +1654,20 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
{
#ifdef pe_use_x86_64
case BITS_AND_SHIFT (64, 0):
- reloc_data[total_relocs].type = 10;
+ reloc_data[total_relocs].type = IMAGE_REL_BASED_DIR64;
total_relocs++;
break;
#endif
case BITS_AND_SHIFT (32, 0):
- reloc_data[total_relocs].type = 3;
+ reloc_data[total_relocs].type = IMAGE_REL_BASED_HIGHLOW;
total_relocs++;
break;
case BITS_AND_SHIFT (16, 0):
- reloc_data[total_relocs].type = 2;
+ reloc_data[total_relocs].type = IMAGE_REL_BASED_LOW;
total_relocs++;
break;
case BITS_AND_SHIFT (16, 16):
- reloc_data[total_relocs].type = 4;
+ reloc_data[total_relocs].type = IMAGE_REL_BASED_HIGHADJ;
/* FIXME: we can't know the symbol's right value
yet, but we probably can safely assume that
CE will relocate us in 64k blocks, so leaving
@@ -1676,7 +1676,8 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
total_relocs++;
break;
case BITS_AND_SHIFT (26, 2):
- reloc_data[total_relocs].type = 5;
+ reloc_data[total_relocs].type =
+ IMAGE_REL_BASED_ARM_MOV32;
total_relocs++;
break;
case BITS_AND_SHIFT (24, 2):
@@ -1723,7 +1724,7 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
reloc_sz += 2;
- if (reloc_data[i].type == 4)
+ if (reloc_data[i].type == IMAGE_REL_BASED_HIGHADJ)
reloc_sz += 2;
}
@@ -1758,7 +1759,7 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
reloc_d + reloc_sz);
reloc_sz += 2;
- if (reloc_data[i].type == 4)
+ if (reloc_data[i].type == IMAGE_REL_BASED_HIGHADJ)
{
bfd_put_16 (abfd, reloc_data[i].extra, reloc_d + reloc_sz);
reloc_sz += 2;
--
2.35.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ld: use definitions in generate_reloc rather than raw literals
2022-05-02 13:04 [PATCH] ld: use definitions in generate_reloc rather than raw literals Mark Harmstone
@ 2022-05-18 14:54 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2022-05-18 14:54 UTC (permalink / raw)
To: Mark Harmstone, binutils
Hi Mark,
> Constant names come from the "PE Format" specifications on the Microsoft
> website.
Patch approved - please apply - or ping me if you do not have write access...
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-18 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 13:04 [PATCH] ld: use definitions in generate_reloc rather than raw literals Mark Harmstone
2022-05-18 14:54 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).