Ejemplo n.º 1
0
            public override void DoCommand(binary_library.IBinaryFile output, IList <binary_library.IBinaryFile> inputs, LinkerScriptState state)
            {
                state.prev_section = state.cur_section;

                binary_library.ISection section = output.CreateSection();
                section.Name         = name;
                section.AddrAlign    = addr_align;
                section.IsAlloc      = isalloc;
                section.IsWriteable  = iswrite;
                section.IsExecutable = isexec;
                section.HasData      = hasdata;
                section.LoadAddress  = state.cur_offset;

                state.cur_section     = section;
                state.data[section]   = new List <byte>();
                state.cur_sect_offset = 0;

                if (hasdata && size < 0)
                {
                    switch (size)
                    {
                    case -1:
                        // elf dynamic
                        if (output.Bitness == Bitness.Bits64)
                        {
                            state.cur_section.Length = 464;
                        }
                        else
                        {
                            state.cur_section.Length = 192;
                        }
                        break;

                    case -2:
                        // elf hash
                        int ssize = 8;          // nbuckets + nchain
                        ssize += binary_library.elf.ElfFile.CalculateBucketCount(output.GetSymbolCount()) * 4;
                        ssize += output.GetSymbolCount() * 4;
                        state.cur_section.Length = ssize;
                        break;
                    }
                }
            }