From 426bdc59fb1215781a4f470012ea1ef81aab1aaa Mon Sep 17 00:00:00 2001 From: bebbo Date: Sat, 2 Jun 2018 22:13:01 +0200 Subject: [PATCH] do not use userdata for own purposes... --- bfd/amigaoslink.c | 14 +++++++------- bfd/bfd-in2.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bfd/amigaoslink.c b/bfd/amigaoslink.c index 6fb8a08..feba361 100644 --- a/bfd/amigaoslink.c +++ b/bfd/amigaoslink.c @@ -172,7 +172,7 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti if (strcmp(s->name, ".text")) continue; - s->userdata = (void *)s->_raw_size; + s->compressed_size = s->_raw_size; } /** @@ -200,7 +200,7 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti // reset rawsize unsigned cursize = s->_raw_size; - s->_raw_size = (unsigned)s->userdata; + s->_raw_size = s->compressed_size; amiga_reloc_type *src; @@ -313,15 +313,15 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti rel_jumps_count = 0; /* adjust memory for first section. */ - if ((unsigned)input_section->userdata < input_section->_raw_size) + if (input_section->compressed_size < input_section->_raw_size) { PTR odata = data; data = bfd_alloc(abfd, input_section->_raw_size); - memcpy(data, odata, (unsigned)input_section->userdata); + memcpy(data, odata, input_section->compressed_size); } /** - * Now all sections have its final offset and size plus the old size in userdata. + * Now all sections have its final offset and size plus the old size in compressed_size. */ } @@ -382,8 +382,8 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti fflush(stdout); // 1. append a long jump - signed endpos = (unsigned)input_section->userdata; - input_section->userdata = (void *)((unsigned)input_section->userdata + 6); + signed endpos = input_section->compressed_size; + input_section->compressed_size += 6; data[endpos] = 0x4e; data[endpos + 1] = 0xf9; data[endpos + 2] = 0; diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 54d6828..b99c098 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1328,6 +1328,9 @@ typedef struct sec been done, then this value will be bigger. */ bfd_size_type _raw_size; + /* The compressed size of the section in octets. */ + bfd_size_type compressed_size; + /* If this section is going to be output, then this value is the offset in *bytes* into the output section of the first byte in the input section (byte ==> smallest addressable unit on the