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
2740typedef struct SectionMergeInfo {2740typedef struct SectionMergeInfo {
2741 Section *s; /* corresponding existing section */2741 Section *s; /* corresponding existing section */
2742 unsigned long offset; /* offset of the new section in the existing section */2742 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 */
2743 uint8_t new_section; /* true if section 's' was added */2744 uint8_t new_section; /* true if section 's' was added */
2744 uint8_t link_once; /* true if link once section */2745 uint8_t link_once; /* true if link once section */
2745} SectionMergeInfo;2746} SectionMergeInfo;
@@ -2779,7 +2780,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 33 unmodified lines
2779 ElfW(Sym) *sym, *symtab;2780 ElfW(Sym) *sym, *symtab;
2780 ElfW_Rel *rel;2781 ElfW_Rel *rel;
2781 Section *s;2782 Section *s;
2782 unsigned int *used_offset;
2783 2783
2784 lseek(fd, file_offset, SEEK_SET);2784 lseek(fd, file_offset, SEEK_SET);
2785 if (tcc_object_type(fd, &ehdr) != AFF_BINTYPE_REL)2785 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
2795 shdr = load_data(fd, file_offset + ehdr.e_shoff,2795 shdr = load_data(fd, file_offset + ehdr.e_shoff,
2796 sizeof(ElfW(Shdr)) * ehdr.e_shnum);2796 sizeof(ElfW(Shdr)) * ehdr.e_shnum);
2797 sm_table = tcc_mallocz(sizeof(SectionMergeInfo) * ehdr.e_shnum);2797 sm_table = tcc_mallocz(sizeof(SectionMergeInfo) * ehdr.e_shnum);
2798 used_offset = tcc_mallocz(sizeof(*used_offset) * s1->nb_sections);
2799 2798
2800 /* load section names */2799 /* load section names */
2801 sh = &shdr[ehdr.e_shstrndx];2800 sh = &shdr[ehdr.e_shstrndx];
@@ -2892,8 +2891,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 90 unmodified lines
2892 s->sh_addralign = sh->sh_addralign;2891 s->sh_addralign = sh->sh_addralign;
2893 s->sh_entsize = sh->sh_entsize;2892 s->sh_entsize = sh->sh_entsize;
2894 sm_table[i].new_section = 1;2893 sm_table[i].new_section = 1;
2895 used_offset = tcc_realloc(used_offset, sizeof(*used_offset) * s1->nb_sections);
2896 used_offset[j] = 0;
2897 found:2894 found:
2898 if (sh->sh_type != s->sh_type) {2895 if (sh->sh_type != s->sh_type) {
2899#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD2896#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
@@ -2908,8 +2905,8 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 8 unmodified lines
2908 s->data_offset += -s->data_offset & (sh->sh_addralign - 1);2905 s->data_offset += -s->data_offset & (sh->sh_addralign - 1);
2909 if (sh->sh_addralign > s->sh_addralign)2906 if (sh->sh_addralign > s->sh_addralign)
2910 s->sh_addralign = sh->sh_addralign;2907 s->sh_addralign = sh->sh_addralign;
2911 sm_table[i].offset = used_offset[j] + s->data_offset;2908 sm_table[i].offset = s->data_offset;
2912 used_offset[j] = sm_table[i].offset;2909 sm_table[i].size = sh->sh_size;
2913 sm_table[i].s = s;2910 sm_table[i].s = s;
2914 /* concatenate sections */2911 /* concatenate sections */
2915 size = sh->sh_size;2912 size = sh->sh_size;
@@ -2998,11 +2995,14 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 82 unmodified lines
2998 continue;2995 continue;
2999 sh = &shdr[i];2996 sh = &shdr[i];
3000 offset = sm_table[i].offset;2997 offset = sm_table[i].offset;
2998 size = sm_table[i].size;
3001 switch(s->sh_type) {2999 switch(s->sh_type) {
3002 case SHT_RELX:3000 case SHT_RELX:
3003 /* take relocation offset information */3001 /* take relocation offset information */
3004 offseti = sm_table[sh->sh_info].offset;3002 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++) {
3006 int type;3006 int type;
3007 unsigned sym_index;3007 unsigned sym_index;
3008 /* convert symbol index */3008 /* convert symbol index */
@@ -3054,7 +3054,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 45 unmodified lines
3054 tcc_free(strtab);3054 tcc_free(strtab);
3055 tcc_free(old_to_new_syms);3055 tcc_free(old_to_new_syms);
3056 tcc_free(sm_table);3056 tcc_free(sm_table);
3057 tcc_free(used_offset);
3058 tcc_free(strsec);3057 tcc_free(strsec);
3059 tcc_free(shdr);3058 tcc_free(shdr);
3060 return ret;3059 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