Clang function-sections flag

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang function-sections flag

shirley breuer via cfe-dev

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev

Hey Paul,

 

I tried that already and got:

“error: unknown argument: '-fno-function-sections'”

 

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf – however the flag is not supported (not with -Xclang but also not without)

However “-ffunction-sections” is accepted (with -Xclang)

 

Kind greetings

Björn

 

From: [hidden email] <[hidden email]>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: RE: Clang function-sections flag

 

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev

Looks like CloudABI is the only triple that uses it by default. Presumably you aren’t on that, but I could also be missing something.

 

For me, it looks like BOTH -ffunction-sections and -fno-function-sections are unknown arguments in clang-cl, however if you use the /clang: syntax, both work.  Can you try that?

 

/clang:-fno-function-sections

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 7:00 AM
To: [hidden email]; [hidden email]
Subject: Re: [cfe-dev] Clang function-sections flag

 

Hey Paul,

 

I tried that already and got:

“error: unknown argument: '-fno-function-sections'”

 

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf – however the flag is not supported (not with -Xclang but also not without)

However “-ffunction-sections” is accepted (with -Xclang)

 

Kind greetings

Björn

 

From: [hidden email] <[hidden email]>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: RE: Clang function-sections flag

 

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev

Using /clang:-fno-function-sections and /clang:-ffunction-sections were both accepted by Clang-cl while /clang:-planschbecken was rejected.

 

Seems like that worked O_O Thank you!
I gonna check if this will make a difference now.

 

In the meantime… why isn’t /clang: and -Xclang the same?!

 

From: Keane, Erich <[hidden email]>
Sent: 20 January 2021 16:07
To: Gaier, Bjoern <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Looks like CloudABI is the only triple that uses it by default. Presumably you aren’t on that, but I could also be missing something.

 

For me, it looks like BOTH -ffunction-sections and -fno-function-sections are unknown arguments in clang-cl, however if you use the /clang: syntax, both work.  Can you try that?

 

/clang:-fno-function-sections

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 7:00 AM
To: [hidden email]; [hidden email]
Subject: Re: [cfe-dev] Clang function-sections flag

 

Hey Paul,

 

I tried that already and got:

“error: unknown argument: '-fno-function-sections'”

 

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf – however the flag is not supported (not with -Xclang but also not without)

However “-ffunction-sections” is accepted (with -Xclang)

 

Kind greetings

Björn

 

From: [hidden email] <[hidden email]>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: RE: Clang function-sections flag

 

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev

/clang: sends to the ‘driver’.  -Xclang sends to the ‘compiler instance’ (the -cc1 compiler), which the driver calls.  They are actually the same executable which makes it a touch more confusing.

 

From: Gaier, Bjoern <[hidden email]>
Sent: Wednesday, January 20, 2021 7:11 AM
To: Keane, Erich <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Using /clang:-fno-function-sections and /clang:-ffunction-sections were both accepted by Clang-cl while /clang:-planschbecken was rejected.

 

Seems like that worked O_O Thank you!
I gonna check if this will make a difference now.

 

In the meantime… why isn’t /clang: and -Xclang the same?!

 

From: Keane, Erich <[hidden email]>
Sent: 20 January 2021 16:07
To: Gaier, Bjoern <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Looks like CloudABI is the only triple that uses it by default. Presumably you aren’t on that, but I could also be missing something.

 

For me, it looks like BOTH -ffunction-sections and -fno-function-sections are unknown arguments in clang-cl, however if you use the /clang: syntax, both work.  Can you try that?

 

/clang:-fno-function-sections

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 7:00 AM
To: [hidden email]; [hidden email]
Subject: Re: [cfe-dev] Clang function-sections flag

 

Hey Paul,

 

I tried that already and got:

“error: unknown argument: '-fno-function-sections'”

 

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf – however the flag is not supported (not with -Xclang but also not without)

However “-ffunction-sections” is accepted (with -Xclang)

 

Kind greetings

Björn

 

From: [hidden email] <[hidden email]>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: RE: Clang function-sections flag

 

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev

Allright :’D

 

That worked! Now my 100x functions are in one section! Thank you so much guys!

 

From: Keane, Erich <[hidden email]>
Sent: 20 January 2021 16:13
To: Gaier, Bjoern <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

/clang: sends to the ‘driver’.  -Xclang sends to the ‘compiler instance’ (the -cc1 compiler), which the driver calls.  They are actually the same executable which makes it a touch more confusing.

 

From: Gaier, Bjoern <[hidden email]>
Sent: Wednesday, January 20, 2021 7:11 AM
To: Keane, Erich <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Using /clang:-fno-function-sections and /clang:-ffunction-sections were both accepted by Clang-cl while /clang:-planschbecken was rejected.

 

Seems like that worked O_O Thank you!
I gonna check if this will make a difference now.

 

In the meantime… why isn’t /clang: and -Xclang the same?!

 

From: Keane, Erich <[hidden email]>
Sent: 20 January 2021 16:07
To: Gaier, Bjoern <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Looks like CloudABI is the only triple that uses it by default. Presumably you aren’t on that, but I could also be missing something.

 

For me, it looks like BOTH -ffunction-sections and -fno-function-sections are unknown arguments in clang-cl, however if you use the /clang: syntax, both work.  Can you try that?

 

/clang:-fno-function-sections

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 7:00 AM
To: [hidden email]; [hidden email]
Subject: Re: [cfe-dev] Clang function-sections flag

 

Hey Paul,

 

I tried that already and got:

“error: unknown argument: '-fno-function-sections'”

 

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf – however the flag is not supported (not with -Xclang but also not without)

However “-ffunction-sections” is accepted (with -Xclang)

 

Kind greetings

Björn

 

From: [hidden email] <[hidden email]>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: RE: Clang function-sections flag

 

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang function-sections flag

shirley breuer via cfe-dev
Looks like everything is set, but let me try to explain a little bit.

The /O1 and /O2 options of MSVC and clang-cl actually expand to several other options. You can see this in the docs:
/O2 (Maximize Speed) /Og /Oi /Ot /Oy /Ob2 /GF /Gy

In particular, /Gy means -ffunction-sections. If you were building your code with optimizations enabled, (`clang-cl /O2 /c foo.cpp`), that would explain why you see one section per function.

If you want to disable function sections more directly, consider passing the /Gy- flag after the /O2 flag.

On Wed, Jan 20, 2021 at 7:17 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Allright :’D

 

That worked! Now my 100x functions are in one section! Thank you so much guys!

 

From: Keane, Erich <[hidden email]>
Sent: 20 January 2021 16:13
To: Gaier, Bjoern <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

/clang: sends to the ‘driver’.  -Xclang sends to the ‘compiler instance’ (the -cc1 compiler), which the driver calls.  They are actually the same executable which makes it a touch more confusing.

 

From: Gaier, Bjoern <[hidden email]>
Sent: Wednesday, January 20, 2021 7:11 AM
To: Keane, Erich <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Using /clang:-fno-function-sections and /clang:-ffunction-sections were both accepted by Clang-cl while /clang:-planschbecken was rejected.

 

Seems like that worked O_O Thank you!
I gonna check if this will make a difference now.

 

In the meantime… why isn’t /clang: and -Xclang the same?!

 

From: Keane, Erich <[hidden email]>
Sent: 20 January 2021 16:07
To: Gaier, Bjoern <[hidden email]>; [hidden email]; clang developer list <[hidden email]>
Subject: RE: Clang function-sections flag

 

Looks like CloudABI is the only triple that uses it by default. Presumably you aren’t on that, but I could also be missing something.

 

For me, it looks like BOTH -ffunction-sections and -fno-function-sections are unknown arguments in clang-cl, however if you use the /clang: syntax, both work.  Can you try that?

 

/clang:-fno-function-sections

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 7:00 AM
To: [hidden email]; [hidden email]
Subject: Re: [cfe-dev] Clang function-sections flag

 

Hey Paul,

 

I tried that already and got:

“error: unknown argument: '-fno-function-sections'”

 

I use Clang-Cl under Windows, creating an ELF file for x86_64-pc-windows-elf – however the flag is not supported (not with -Xclang but also not without)

However “-ffunction-sections” is accepted (with -Xclang)

 

Kind greetings

Björn

 

From: [hidden email] <[hidden email]>
Sent: 20 January 2021 15:56
To: Gaier, Bjoern <[hidden email]>; [hidden email]
Subject: RE: Clang function-sections flag

 

Try adding -fno-function-sections to make sure it’s turned off (sounds like it is on by default for your target).

--paulr

 

From: cfe-dev <[hidden email]> On Behalf Of Gaier, Bjoern via cfe-dev
Sent: Wednesday, January 20, 2021 5:01 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Clang function-sections flag

 

Hey Clang-people,

 

I have a nooby question about the -ffunction-sections flag of Clang.

As far as I used to understand, setting this flag means, that every function gets their own section. Makes sense so far.

 

Recently I started to look into the ELF format a bit so that subject came up. I created a macro to quickly generate me some functions:

#define wuff(a, b) \

a##b

 

#define crap(num) \

int wuff(schwimmflugel, num) () \

{ \

    return num; \

}

 

Creating the object file and looking into it, I found a section header for every of my functions no matter if I set the -ffunction-sections flag or not.

Also setting my function to static didn't changed a thing.... well besides from having those functions striped from my object file xD

 

So... what does that flag effect?

 

Kind greetings

Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev