void asmbelfsetup(void) { Section *sect; /* This null SHdr must appear before all others */ elfshname(""); for(sect=segtext.sect; sect!=nil; sect=sect->next) elfshalloc(sect); for(sect=segdata.sect; sect!=nil; sect=sect->next) elfshalloc(sect); }
ElfShdr* elfshbits(Section *sect) { ElfShdr *sh; sh = elfshalloc(sect); if(sh->type > 0) return sh; if(sect->vaddr < sect->seg->vaddr + sect->seg->filelen) sh->type = SHT_PROGBITS; else sh->type = SHT_NOBITS; sh->flags = SHF_ALLOC; if(sect->rwx & 1) sh->flags |= SHF_EXECINSTR; if(sect->rwx & 2) sh->flags |= SHF_WRITE; if(!isobj) sh->addr = sect->vaddr; sh->addralign = PtrSize; sh->size = sect->len; sh->off = sect->seg->fileoff + sect->vaddr - sect->seg->vaddr; return sh; }
ElfShdr* elfshbits(Section *sect) { ElfShdr *sh; sh = elfshalloc(sect); if(sh->type > 0) return sh; if(sect->vaddr < sect->seg->vaddr + sect->seg->filelen) sh->type = SHT_PROGBITS; else sh->type = SHT_NOBITS; sh->flags = SHF_ALLOC; if(sect->rwx & 1) sh->flags |= SHF_EXECINSTR; if(sect->rwx & 2) sh->flags |= SHF_WRITE; if(strcmp(sect->name, ".tbss") == 0) { sh->flags |= SHF_TLS; sh->type = SHT_NOBITS; } if(linkmode != LinkExternal) sh->addr = sect->vaddr; sh->addralign = sect->align; sh->size = sect->len; sh->off = sect->seg->fileoff + sect->vaddr - sect->seg->vaddr; return sh; }