This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Linker plugin API.
- From: Oleg Ogurtsov <o dot ogurtsov at samsung dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Wed, 23 May 2018 11:12:35 +0300
- Subject: Re: Linker plugin API.
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180523081241euoutp01783f5385b441f895e42531a06493b3f5~xN9qvfFXX1134811348euoutp01E
- References: <CGME20180420121355eucas1p1cc7fc0d940d689707079571ec3c5e54a@eucas1p1.samsung.com> <2b7ed02f-a914-30cc-9b56-e746fa2634d2@samsung.com> <CAJimCsEaWZ5MoJQVuNOF=_GV56mGgCqWLYqj+RYf5NgzROO6vw@mail.gmail.com> <f850ff4c-86f5-0e05-a8d9-cc494d835c51@samsung.com>
I moved the new statement and bfd section after section ".note.ABI-tag".
Now I have correct vma and offset, but I can't setup a content.
If I use the bfd_set_section_contents API function, then I get an
incorrect output file.
If I set the contents pointer (in bfd_section) to my buffer, then the
output section will be filled with zero. And the output file can be
executed correctly.
How to setup a content? What am I missing?
On 05/21/2018 11:40 AM, Oleg Ogurtsov wrote:
> I maked the new output statement and bfd section in ldlang.c inside
> lang_place_orphans().
> The section is created with flags (ALLOC, LOAD, !RELOC, READ ONLY,
> HAS_CONTENTS, !NEVER_LOAD, !IS_COMMON, !MERGE, !SEC_GROUP,
> !LINKER_HAS_INPUT), but has wrong VMA and offset in output file.
> What am I missing?
>
> On 04/23/2018 07:13 PM, Cary Coutant wrote:
>>> Is it possible to add/change/delete ELF Note sections from the linker
>>> plugin?
>>> I have object files with PT_NOTE sections and non-standard fields. The
>>> linker add fields from all object files to the output file.
>>> I want to process fields and get one result field for output file. Is it
>>> possible from plugin?
>>> Where it is better to make such processing?
>>> I would be grateful for the help.
>>
>> The plugin API currently doesn't have any way to do something like
>> this. It's theoretically possible, but it would take some pretty deep
>> hooks in the linker to add plugin support for section merging and
>> rewriting like this.
>>
>> If you need it done at link time, I would suggest using a new
>> vendor-specific section type instead of SHT_NOTE, and you can add
>> built-in support to the linker for that section type. I'd prefer to
>> discourage the overuse of SHT_NOTE sections for information that is
>> more than mere notes.
>>
>> -cary
Best regards,
Oleg Ogurtsov.