radeonsi: make radeon_shader_reloc name string fixed-sized
authorMarek Olšák <marek.olsak@amd.com>
Thu, 11 Feb 2016 22:20:38 +0000 (23:20 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 21 Feb 2016 20:08:58 +0000 (21:08 +0100)
This will simplify implementations of binary shaders.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/radeon_elf_util.c

index ee173d35880cce4bb3afa56106881c5699992ef0..7df617737a70442f4727dfdab67733c3bcb57d1b 100644 (file)
@@ -97,7 +97,7 @@ struct r600_common_context;
 struct r600_perfcounters;
 
 struct radeon_shader_reloc {
-       char *name;
+       char name[32];
        uint64_t offset;
 };
 
index 2e45d439e7a0d4078d2a5d3ac575db8a80465d78..70a2c4dc0981130a8f3dd4e1f487f4e3fbd7a6ea 100644 (file)
@@ -98,7 +98,8 @@ static void parse_relocs(Elf *elf, Elf_Data *relocs, Elf_Data *symbols,
                symbol_name = elf_strptr(elf, symbol_sh_link, symbol.st_name);
 
                reloc->offset = rel.r_offset;
-               reloc->name = strdup(symbol_name);
+               strncpy(reloc->name, symbol_name, sizeof(reloc->name)-1);
+               reloc->name[sizeof(reloc->name)-1] = 0;
        }
 }
 
@@ -198,10 +199,6 @@ const unsigned char *radeon_shader_binary_config_start(
 void radeon_shader_binary_free_relocs(struct radeon_shader_reloc *relocs,
                                        unsigned reloc_count)
 {
-       unsigned i;
-       for (i = 0; i < reloc_count; i++) {
-               FREE(relocs[i].name);
-       }
        FREE(relocs);
 }