// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_section
void elf32_section(struct GlobalVars *gv,struct Elf32_Ehdr *ehdr,
                   struct ObjectUnit *ou,struct Elf32_Shdr *shdr,
                   int shndx,char *shstrtab)
/* create a new section */
{
  bool be = (ehdr->e_ident[EI_DATA] == ELFDATA2MSB);
  struct LinkFile *lf = ou->lnkfile;
  char *sec_name = shstrtab + read32(be,shdr->sh_name);
  uint8_t *data = (uint8_t *)ehdr + read32(be,shdr->sh_offset);
  unsigned long size = (unsigned long)read32(be,shdr->sh_size);
  uint32_t f = read32(be,shdr->sh_flags);
  uint8_t type=ST_DATA,flags=0,prot=SP_READ;
  struct Section *s;

  if (gv->strip_symbols>=STRIP_DEBUG &&
      (!strncmp(sec_name,".debug",6) ||
       !strncmp(sec_name,".line",5) ||
       !strncmp(sec_name,".stab",5)))
    return;   /* ignore debugging sections when -S or -s is given */

  if (read32(be,shdr->sh_type) == SHT_NOBITS) {
    data = NULL;
    type = ST_UDATA;
    flags |= SF_UNINITIALIZED;
  }
  else {
    if (data+size > lf->data+lf->length)  /* illegal section offset */
      error(49,lf->pathname,sec_name,lf->objname);
  }

  if ((f & SHF_EXECINSTR) && data) {
    type = ST_CODE;
    prot |= SP_EXEC;
  }
  if (f & SHF_WRITE)
    prot |= SP_WRITE;
  if (f & SHF_ALLOC)
    flags |= SF_ALLOC;
  if (!strncmp(sec_name,".gnu.linkonce",13))
    flags |= SF_LINKONCE;

  s = add_section(ou,sec_name,data,size,type,flags,prot,
                  (uint8_t)shiftcnt(read32(be,shdr->sh_addralign)),FALSE);

  s->link = read32(be,shdr->sh_link);  /* save link for later use */
  s->id = shndx;  /* use section header index for identification */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movl %r8d, 0x2c(%rsp)
movq %rcx, %r14
movq %rdi, %r12
xorl %ebp, %ebp
movq %rsi, 0x20(%rsp)
cmpb $0x2, 0x5(%rsi)
sete %bpl
movq %rdx, 0x40(%rsp)
movq 0x10(%rdx), %rax
movq %rax, 0x38(%rsp)
movl %ebp, %edi
movq %rcx, %rsi
callq 0x664d
movl %eax, %r13d
addq %rbx, %r13
leaq 0x10(%r14), %rsi
movl %ebp, %edi
callq 0x664d
movl %eax, 0x28(%rsp)
leaq 0x14(%r14), %rsi
movl %ebp, %edi
callq 0x664d
movl %eax, %r15d
leaq 0x8(%r14), %rsi
movl %ebp, %edi
callq 0x664d
movl %eax, %ebx
cmpb $0x0, 0x6c(%r12)
je 0x13320
leaq 0xe5a1(%rip), %rsi      # 0x2187a
pushq $0x6
popq %rdx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
je 0x1343d
leaq 0xe1f2(%rip), %rsi      # 0x214e5
pushq $0x5
popq %rdx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
je 0x1343d
leaq 0xe579(%rip), %rsi      # 0x21886
pushq $0x5
popq %rdx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
je 0x1343d
movl %r15d, %r15d
leaq 0x4(%r14), %rsi
movl %ebp, %edi
callq 0x664d
cmpl $0x8, %eax
movq %r15, 0x30(%rsp)
jne 0x13342
movb $0x2, %dl
movb $0x3, %r15b
xorl %r12d, %r12d
jmp 0x1337e
movl 0x28(%rsp), %eax
movq 0x20(%rsp), %r12
addq %rax, %r12
leaq (%r12,%r15), %rax
movq 0x38(%rsp), %rdx
movq 0x28(%rdx), %rcx
addq 0x30(%rdx), %rcx
movb $0x2, %r15b
cmpq %rcx, %rax
jbe 0x1337c
movq 0x10(%rdx), %rsi
movq 0x20(%rdx), %rcx
pushq $0x31
popq %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x6c19
xorl %edx, %edx
movq %r12, 0x20(%rsp)
movl %ebx, %eax
shrb $0x2, %al
testq %r12, %r12
setne %cl
andb %al, %cl
movzbl %r15b, %eax
pushq $0x1
popq %r15
cmovel %eax, %r15d
shlb $0x2, %cl
leal (%rbx,%rbx), %r12d
andb $0x2, %r12b
orb %cl, %r12b
incb %r12b
shrb %bl
andb $0x1, %bl
orb %dl, %bl
leaq 0xe130(%rip), %rsi      # 0x214eb
pushq $0xd
popq %rdx
movq %r13, %rdi
callq 0x5070
leal 0x8(%rbx), %ecx
testl %eax, %eax
movzbl %bl, %eax
movzbl %cl, %ebx
cmovnel %eax, %ebx
leaq 0x20(%r14), %rsi
movl %ebp, %edi
callq 0x664d
movl %eax, %edi
callq 0x6a50
movl $0xff, %ecx
andl %ecx, %eax
movl %eax, 0x8(%rsp)
movzbl %r12b, %eax
movl %eax, (%rsp)
andl $0x0, 0x10(%rsp)
andl %ecx, %ebx
andl %ecx, %r15d
movq 0x40(%rsp), %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rcx
movl %r15d, %r8d
movl %ebx, %r9d
callq 0xbab3
movq %rax, %rbx
addq $0x18, %r14
movl %ebp, %edi
movq %r14, %rsi
callq 0x664d
movl %eax, 0x90(%rbx)
movl 0x2c(%rsp), %eax
movl %eax, 0x28(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq