Setup order of target specific segments

11 views
Skip to first unread message

Simon Atanasyan

unread,
May 15, 2015, 12:39:53 PM5/15/15
to mcli...@googlegroups.com
Hi,

Is it possible to change the order of target specific segments in
MCLinker? If I create new segment ABIFLAGS in the
`doCreateProgramHdrs()` function, it goes at the end of the whole
segment list:

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x001a4 0x001a4 R E 0x10000
LOAD 0x010000 0x00010000 0x00010000 0x00098 0x00098 RW 0x10000
DYNAMIC 0x010000 0x00010000 0x00010000 0x00090 0x00090 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0
ABIFLAGS 0x0000d4 0x000000d4 0x000000d4 0x00018 0x00018 R 0x8

What should I do to put ABIFLAGS in the beginning?

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
ABIFLAGS 0x0000d4 0x000000d4 0x000000d4 0x00018 0x00018 R 0x8
LOAD 0x000000 0x00000000 0x00000000 0x001a4 0x001a4 R E 0x10000
LOAD 0x010000 0x00010000 0x00010000 0x00098 0x00098 RW 0x10000
DYNAMIC 0x010000 0x00010000 0x00010000 0x00090 0x00090 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0

Regards,
Simon Atanasyan

Pete Chou

unread,
May 17, 2015, 10:26:05 PM5/17/15
to Simon Atanasyan, mcli...@googlegroups.com
Does the segment order matter?

Thanks,
Pete


--
You received this message because you are subscribed to the Google Groups "MCLinker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mclinker+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Atanasyan

unread,
May 18, 2015, 1:25:04 AM5/18/15
to Pete Chou, mcli...@googlegroups.com
Hi,

In general this is required by ABI:
[[
A single structure is emitted and tagged with a PT_MIPS_ABIFLAGS
program header. This program header must be emitted immediately after
the PT_INTERP header and displaces the PT_MIPS_REGINFO header that
would otherwise follow PT_INTERP.
]]

It is not a mandatory requirement so it is not an urgent problem. But
as far as I understand placing the segment in the beginning might
improve startup performance because the loader first look at this
segment.

Regards,
Simon
--
Simon Atanasyan

Pete Chou

unread,
May 18, 2015, 9:17:59 AM5/18/15
to Simon Atanasyan, mcli...@googlegroups.com
Try to find PT_PHDR or PT_INTERP in `doCreateProgramHdrs()` first, and then use the new `ELFSegmentFactory::insert()` api in commit 4061c4c.

Thanks,
Pete

Simon Atanasyan

unread,
May 19, 2015, 4:11:39 AM5/19/15
to Pete Chou, mcli...@googlegroups.com
Hi Pete,

Thanks a lot for so quick solution!
--
Simon Atanasyan
Reply all
Reply to author
Forward
0 new messages