GNU link "Discarded input sections"

Dustin Sr wrote:
> I have a "Discarded input sections" in my map output from linking, and I
> believe that there are some functions/variables that are getting put in
> this section that I don't want to discarded?

The linker will not create output sections which do not have any
contents. So it seems unlikely that the discarded sections contain
function or variables. It would fail to link if any referenced symbols
did not exist.

The standard sections are:

text - for executable code and read-only data
common/bss - for unitialised globals and statics (zeroed at runtime)
data - for initialised writeable data.

If you have variables of code in any other sections it will be because
you have explicitly placed them there with an attribute specification.
And if you did that, the section should presumably not be discarded.

As ever in these cases it is much better if you were to post the actual
output rather than merely describing it. A copy & paste would be easier
for you and more accurate and informative for us.

Clifford
OP
Clifford Slocombe wrote:
> Dustin Sr wrote:
>> I have a "Discarded input sections" in my map output from linking, and I
>> believe that there are some functions/variables that are getting put in
>> this section that I don't want to discarded?
>
> The linker will not create output sections which do not have any
> contents. So it seems unlikely that the discarded sections contain
> function or variables. It would fail to link if any referenced symbols
> did not exist.
>
> The standard sections are:
>
> text - for executable code and read-only data
> common/bss - for unitialised globals and statics (zeroed at runtime)
> data - for initialised writeable data.
>
> If you have variables of code in any other sections it will be because
> you have explicitly placed them there with an attribute specification.
> And if you did that, the section should presumably not be discarded.
>
> As ever in these cases it is much better if you were to post the actual
> output rather than merely describing it. A copy & paste would be easier
> for you and more accurate and informative for us.
>
> Clifford
Here is a small section of the Discarded input sections.

Discarded input sections

 _ZN2RM7New_WQEEv
                0x00000000        0x0 CfgSer.o
 _ZN2RM4FreeEP7SCmdRec
                0x00000000        0x0 CfgSer.o
 _ZN2RM4FreeEP7BuffSeg
                0x00000000        0x0 CfgSer.o
 _ZN2RM4FreeEP3WQE
                0x00000000        0x0 CfgSer.o
 .text          0x00000000        0x0 CfgSer.o
 .data          0x00000000        0x0 CfgSer.o
 .bss           0x00000000        0x0 CfgSer.o
 .rodata.str1.8
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer9SerRecLUNEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer12SerSixDrivesEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer8SerRdSbkEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer3IRdEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer11SerDumpDoneEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer8ChkPortsEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer9SerCUP_CBEP4WQEe
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer3IWrEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer10SerReadRGLEv
                0x00000000        0x0 CfgSer.o
 .text._ZN6CfgSer6SerCUPEv
                0x00000000        0x0 CfgSer.o

Reply

A question of your own? This thread is over 19 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.