History

Real fix include SHT_NOTE sections everywhere

Thinko in last commit

herman ten brugge committed 5 years ago

Commit 85b6efb1 parent 766bd821 file · +7 −8Browse files

Unified · Split

tccelf.c+7−8
@@ -2740,6 +2740,7 @@ ST_FUNC void *load_data(int fd, unsigned long file_offset, unsigned long size) · 2739 unmodified lines
27402740 typedef struct SectionMergeInfo {
27412741 Section *s; /* corresponding existing section */
27422742 unsigned long offset; /* offset of the new section in the existing section */
2743+ unsigned long size; /* size of the new section in the existing section */
27432744 uint8_t new_section; /* true if section 's' was added */
27442745 uint8_t link_once; /* true if link once section */
27452746 } SectionMergeInfo;
@@ -2779,7 +2780,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 33 unmodified lines
27792780 ElfW(Sym) *sym, *symtab;
27802781 ElfW_Rel *rel;
27812782 Section *s;
2782− unsigned int *used_offset;
27832783
27842784 lseek(fd, file_offset, SEEK_SET);
27852785 if (tcc_object_type(fd, &ehdr) != AFF_BINTYPE_REL)
@@ -2795,7 +2795,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 9 unmodified lines
27952795 shdr = load_data(fd, file_offset + ehdr.e_shoff,
27962796 sizeof(ElfW(Shdr)) * ehdr.e_shnum);
27972797 sm_table = tcc_mallocz(sizeof(SectionMergeInfo) * ehdr.e_shnum);
2798− used_offset = tcc_mallocz(sizeof(*used_offset) * s1->nb_sections);
27992798
28002799 /* load section names */
28012800 sh = &shdr[ehdr.e_shstrndx];
@@ -2892,8 +2891,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 90 unmodified lines
28922891 s->sh_addralign = sh->sh_addralign;
28932892 s->sh_entsize = sh->sh_entsize;
28942893 sm_table[i].new_section = 1;
2895− used_offset = tcc_realloc(used_offset, sizeof(*used_offset) * s1->nb_sections);
2896− used_offset[j] = 0;
28972894 found:
28982895 if (sh->sh_type != s->sh_type) {
28992896 #if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
@@ -2908,8 +2905,8 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 8 unmodified lines
29082905 s->data_offset += -s->data_offset & (sh->sh_addralign - 1);
29092906 if (sh->sh_addralign > s->sh_addralign)
29102907 s->sh_addralign = sh->sh_addralign;
2911− sm_table[i].offset = used_offset[j] + s->data_offset;
2912− used_offset[j] = sm_table[i].offset;
2908+ sm_table[i].offset = s->data_offset;
2909+ sm_table[i].size = sh->sh_size;
29132910 sm_table[i].s = s;
29142911 /* concatenate sections */
29152912 size = sh->sh_size;
@@ -2998,11 +2995,14 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 82 unmodified lines
29982995 continue;
29992996 sh = &shdr[i];
30002997 offset = sm_table[i].offset;
2998+ size = sm_table[i].size;
30012999 switch(s->sh_type) {
30023000 case SHT_RELX:
30033001 /* take relocation offset information */
30043002 offseti = sm_table[sh->sh_info].offset;
3005− for_each_elem(s, (offset / sizeof(*rel)), rel, ElfW_Rel) {
3003+ for (rel = (ElfW_Rel *) s->data + (offset / sizeof(*rel));
3004+ rel < (ElfW_Rel *) s->data + ((offset + size) / sizeof(*rel));
3005+ rel++) {
30063006 int type;
30073007 unsigned sym_index;
30083008 /* convert symbol index */
@@ -3054,7 +3054,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 45 unmodified lines
30543054 tcc_free(strtab);
30553055 tcc_free(old_to_new_syms);
30563056 tcc_free(sm_table);
3057− tcc_free(used_offset);
30583057 tcc_free(strsec);
30593058 tcc_free(shdr);
30603059 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t