[nasm:macho-unify] output: macho -- Use native macho_relocation_info_t

nasm-bot for Cyrill Gorcunov gorcunov at gmail.com
Tue Jun 30 17:03:03 PDT 2020


Commit-ID:  3dd7a1ab9806e702c59310d61dc7b79be00901c6
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=3dd7a1ab9806e702c59310d61dc7b79be00901c6
Author:     Cyrill Gorcunov <gorcunov at gmail.com>
AuthorDate: Sat, 5 May 2018 13:30:15 +0300
Committer:  Cyrill Gorcunov <gorcunov at gmail.com>
CommitDate: Wed, 9 May 2018 18:03:50 +0300

output: macho -- Use native macho_relocation_info_t

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>


---
 output/outmacho.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/output/outmacho.c b/output/outmacho.c
index 54c051d5..233efd29 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -1361,17 +1361,21 @@ static uint32_t macho_write_segment (uint64_t offset)
 static void macho_write_relocs (struct reloc *r)
 {
     while (r) {
-	uint32_t word2;
+        macho_relocation_info_t info;
 
-	fwriteint32_t(r->addr, ofile); /* reloc offset */
+        info.r_address          = cpu_to_le32(r->addr);
 
-	word2 = r->snum;
-	word2 |= r->pcrel << 24;
-	word2 |= r->length << 25;
-	word2 |= r->ext << 27;
-	word2 |= r->type << 28;
-	fwriteint32_t(word2, ofile); /* reloc data */
-	r = r->next;
+        info.u.r_symbolnum      = r->snum;
+        info.u.r_pcrel          = r->pcrel;
+        info.u.r_length         = r->length;
+        info.u.r_extern         = r->ext;
+        info.u.r_type           = r->type;
+
+        info.u.r_raw            = cpu_to_le32(info.u.r_raw);
+
+        nasm_write(&info, sizeof(info), ofile);
+
+        r = r->next;
     }
 }
 


More information about the Nasm-commits mailing list