// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %r9, %rbx
movl %r8d, 0xc(%rsp)
movq %rcx, %r14
movq %rdi, %r12
xorl %ebp, %ebp
movq %rsi, (%rsp)
cmpb $0x2, 0x5(%rsi)
sete %bpl
movq %rdx, 0x20(%rsp)
movq 0x10(%rdx), %rax
movq %rax, 0x18(%rsp)
movl %ebp, %edi
movq %rcx, %rsi
callq 0x696f
movl %eax, %r13d
addq %rbx, %r13
leaq 0x10(%r14), %rsi
movl %ebp, %edi
callq 0x696f
movl %eax, 0x8(%rsp)
leaq 0x14(%r14), %rsi
movl %ebp, %edi
callq 0x696f
movl %eax, %r15d
leaq 0x8(%r14), %rsi
movl %ebp, %edi
callq 0x696f
movl %eax, %ebx
cmpb $0x0, 0x6c(%r12)
je 0x1441d
leaq 0xf48a(%rip), %rsi      # 0x2385a
movl $0x6, %edx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
je 0x1453f
leaq 0xf0d9(%rip), %rsi      # 0x234c5
movl $0x5, %edx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
je 0x1453f
leaq 0xf45e(%rip), %rsi      # 0x23866
movl $0x5, %edx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
je 0x1453f
movl %r15d, %r15d
leaq 0x4(%r14), %rsi
movl %ebp, %edi
callq 0x696f
cmpl $0x8, %eax
movq %r15, 0x10(%rsp)
jne 0x1443f
movb $0x2, %dl
movb $0x3, %r15b
xorl %r12d, %r12d
jmp 0x1447c
movl 0x8(%rsp), %eax
movq (%rsp), %r12
addq %rax, %r12
leaq (%r12,%r15), %rax
movq 0x18(%rsp), %rdx
movq 0x28(%rdx), %rcx
addq 0x30(%rdx), %rcx
movb $0x2, %r15b
cmpq %rcx, %rax
jbe 0x1447a
movq 0x10(%rdx), %rsi
movq 0x20(%rdx), %rcx
movl $0x31, %edi
movq %r13, %rdx
xorl %eax, %eax
callq 0x6f14
xorl %edx, %edx
movq %r12, (%rsp)
movl %ebx, %eax
shrb $0x2, %al
testq %r12, %r12
setne %cl
andb %al, %cl
movzbl %r15b, %eax
movl $0x1, %r15d
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 0xf011(%rip), %rsi      # 0x234cb
movl $0xd, %edx
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 0x696f
movl %eax, %edi
callq 0x6dff
movl $0xff, %ecx
andl %ecx, %eax
subq $0x8, %rsp
movzbl %r12b, %r10d
andl %ecx, %ebx
andl %ecx, %r15d
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %r15d, %r8d
movl %ebx, %r9d
pushq $0x0
pushq %rax
pushq %r10
callq 0xc11b
addq $0x20, %rsp
movq %rax, %rbx
addq $0x18, %r14
movl %ebp, %edi
movq %r14, %rsi
callq 0x696f
movl %eax, 0x90(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x28(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq