[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180828165829.woylt7lgoj3qz5up@treble>
Date: Tue, 28 Aug 2018 11:58:29 -0500
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Allan Xavier <allan.x.xavier@...cle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] objtool: Support multiple rodata sections.
On Fri, Aug 03, 2018 at 07:40:40PM +0100, Allan Xavier wrote:
> +static void mark_rodata(struct objtool_file *file)
> +{
> + struct section *sec;
> + bool found = false;
> + static const char *str1 = ".str1.";
> + const int str1len = strlen(str1) + 1;
> +
A comment here would help, explaining that this looks for both .rodata
and .rodata.func_name sections (when using -fdata-sections).
> + for_each_sec(file, sec) {
> + if (strstr(sec->name, ".rodata") == sec->name) {
> + char *str1pos = sec->name + strlen(sec->name) - str1len;
> +
> + /* Skips over .rodata.str1.1 and .rodata.str.1.8 */
> + if (strstr(sec->name, str1) != str1pos) {
> + sec->rodata = true;
> + found = true;
> + }
> + }
> + }
This could be simplified and made more readable with something like:
for_each_sec(file, sec) {
if (!strncmp(sec->name, ".rodata", 7) &&
!strstr(sec->name, ".str1.") {
sec->rodata = true;
found = true;
}
}
--
Josh
Powered by blists - more mailing lists