[Mesa-dev] [PATCH 4/3] radeon, elf: Concatenate all rodata sections.

Jan Vesely jan.vesely at rutgers.edu
Mon May 25 17:13:43 PDT 2015


This prevents leaks and makes sure all data are available.
In case there is only one section it works as before.

Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---

This might break stuff if something relied on previous rodata locations.

 src/gallium/drivers/radeon/radeon_elf_util.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_elf_util.c b/src/gallium/drivers/radeon/radeon_elf_util.c
index 9b50822..a117f61 100644
--- a/src/gallium/drivers/radeon/radeon_elf_util.c
+++ b/src/gallium/drivers/radeon/radeon_elf_util.c
@@ -153,9 +153,12 @@ void radeon_elf_read(const char *elf_data, unsigned elf_size,
 						  (char *)section_data->d_buf);
 		} else if (!strncmp(name, ".rodata", 7)) {
 			section_data = elf_getdata(section, section_data);
-			binary->rodata_size = section_data->d_size;
-			binary->rodata = MALLOC(binary->rodata_size * sizeof(unsigned char));
-			memcpy(binary->rodata, section_data->d_buf, binary->rodata_size);
+			binary->rodata = REALLOC(binary->rodata,
+			                 binary->rodata_size,
+			                 binary->rodata_size + section_data->d_size);
+			memcpy(binary->rodata + binary->rodata_size,
+			       section_data->d_buf, section_data->d_size);
+			binary->rodata_size += section_data->d_size;
 		} else if (!strncmp(name, ".symtab", 7)) {
 			symbols = elf_getdata(section, section_data);
 			symbol_sh_link = section_header.sh_link;
-- 
2.1.0



More information about the mesa-dev mailing list