// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/ldscript.c
// Function: next_secdef
struct LinkedSection *next_secdef(struct GlobalVars *gv)
/* Find next section definition in script and return the machting
   structure. */
{
  char *keyword;
  struct Phdr *p;

  level = 1;
  current_ls = NULL;

  do {
    while (keyword = getword()) {
      if (check_command(gv,keyword,SCMDF_GLOBAL)) {
        continue;
      }
      else if (getchr() == '=') {
        symbol_assignment(gv,keyword,0);
      }

      else {
        /* check for section definition */
        char s_type[MAXLEN];
        struct LinkedSection *ls;
        int ret;
        lword s_addr,s_lma;

        back(1);
        if (ls = find_lnksec(gv,keyword,0,0,0,0)) {
          current_ls = ls;
          if (ret = startofsecdef(&s_addr,s_type,&s_lma)) {
            if (ret & 2)
              change_address(ls->relocmem,s_addr);
            if (ret & 4) {
              if (ls->destmem == ls->relocmem)
                ls->destmem = add_memblock("lma",MEM_DEFORG,MEM_DEFLEN);
              change_address(ls->destmem,s_lma);
            }

            secdefbase = NULL;
            return ls;
          }
        }
        else
          ierror("next_secdef(): No Section for %s defined",keyword);
      }
    }
  }
  while (getchr() == ';');
  back(1);

#if 0 /* @@@ don't do it - it modifies header size !!! */
  /* scan for empty segments and declare them as unused */
  for (p=gv->phdrlist; p; p=p->next) {
    if (p->type!=PT_PHDR && (p->start==ADDR_NONE || p->start_vma==ADDR_NONE)) {
      p->start = p->start_vma = p->file_end = p->mem_end = 0;
      p->flags &= ~PHDR_USED;
    }
  }
#endif
  return NULL;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x138(%rsp)
movl $0x1, 0x2e403(%rip)     # 0x449ec
movq $0x0, 0x2e3e4(%rip) # 0x449d8
jmp 0x165f6
callq 0x167b0
movq %rax, 0x130(%rsp)
cmpq $0x0, %rax
je 0x1676e
movq 0x138(%rsp), %rdi
movq 0x130(%rsp), %rsi
movl $0x2, %edx
callq 0x14dd0
cmpl $0x0, %eax
je 0x1662e
jmp 0x165f6
callq 0x18790
movsbl %al, %eax
cmpl $0x3d, %eax
jne 0x16657
movq 0x138(%rsp), %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0x15a10
jmp 0x16767
movl $0x1, %edi
callq 0x18830
movq 0x138(%rsp), %rdi
movq 0x130(%rsp), %rsi
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x12110
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x1674f
movq 0x18(%rsp), %rax
movq %rax, 0x2e33b(%rip)     # 0x449d8
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdi
movq %rsp, %rdx
callq 0x167c0
movl %eax, 0x14(%rsp)
cmpl $0x0, %eax
je 0x1674d
movl 0x14(%rsp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x166db
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rdi
movq 0x8(%rsp), %rsi
callq 0x16a60
movl 0x14(%rsp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x16733
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jne 0x16721
leaq 0x1f494(%rip), %rdi     # 0x35b96
xorl %eax, %eax
movl %eax, %esi
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
callq 0x16b10
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rdi
movq (%rsp), %rsi
callq 0x16a60
movq $0x0, 0x2e2a2(%rip) # 0x449e0
movq 0x18(%rsp), %rax
movq %rax, 0x140(%rsp)
jmp 0x16797
jmp 0x16765
movq 0x130(%rsp), %rsi
leaq 0x1f43c(%rip), %rdi     # 0x35b9a
movb $0x0, %al
callq 0x8ae0
jmp 0x16767
jmp 0x16769
jmp 0x165f6
jmp 0x16770
callq 0x18790
movsbl %al, %eax
cmpl $0x3b, %eax
je 0x165f4
movl $0x1, %edi
callq 0x18830
movq $0x0, 0x140(%rsp)
movq 0x140(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
nopw (%rax,%rax)