// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movl $0x1, 0x24cb2(%rip)     # 0x3361c
movq $0x0, 0x24c93(%rip) # 0x33608
leaq 0x10(%rsp), %r12
movq %rsp, %r13
movl $0x1, %edi
callq 0x100e6
testq %rax, %rax
je 0xe9bb
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
movl $0x2, %edx
callq 0xda00
testl %eax, %eax
jne 0xe97d
callq 0x1006f
cmpb $0x3d, %al
jne 0xe9c9
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xe363
jmp 0xe97d
callq 0x1006f
cmpb $0x3b, %al
je 0xe97d
jmp 0xea8d
movl $0x1, %edi
callq 0x100d3
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
je 0xea6a
movq %rax, %rbp
movq %rax, 0x24c11(%rip)     # 0x33608
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xeaae
testl %eax, %eax
je 0xea7b
movl %eax, %r14d
testb $0x2, %r14b
je 0xea22
movq 0x30(%rbp), %rdi
movq 0x8(%rsp), %rsi
callq 0xec97
cmpl $0x4, %r14d
jb 0xea5b
movq 0x28(%rbp), %rax
cmpq 0x30(%rbp), %rax
jne 0xea4e
leaq 0x14169(%rip), %rdi     # 0x22ba2
xorl %esi, %esi
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
callq 0xecda
movq %rax, 0x28(%rbp)
movq 0x28(%rbp), %rdi
movq (%rsp), %rsi
callq 0xec97
movq $0x0, 0x24baa(%rip) # 0x33610
xorl %eax, %eax
jmp 0xea80
leaq 0x14135(%rip), %rdi     # 0x22ba6
movq %r14, %rsi
xorl %eax, %eax
callq 0x52b0
movb $0x1, %al
movq %r15, %rbp
movq %rbp, %r15
testb %al, %al
jne 0xe97d
jmp 0xea99
movl $0x1, %edi
callq 0x100d3
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq