diff mbox series

[RFC,v5,04/57] objtool: check: Ignore empty alternative groups

Message ID 20200109160300.26150-5-jthierry@redhat.com (mailing list archive)
State New, archived
Headers show
Series objtool: Add support for arm64 | expand

Commit Message

Julien Thierry Jan. 9, 2020, 4:02 p.m. UTC
Atlernative section can contain entries for alternatives with no
instructions. Objtool will currently crash when handling such an entry.

Just skip that entry, but still give a warning to discourage useless
entries.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
---
 tools/objtool/check.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Josh Poimboeuf Jan. 21, 2020, 4:30 p.m. UTC | #1
On Thu, Jan 09, 2020 at 04:02:07PM +0000, Julien Thierry wrote:
> Atlernative section can contain entries for alternatives with no
> instructions. Objtool will currently crash when handling such an entry.
> 
> Just skip that entry, but still give a warning to discourage useless
> entries.
> 
> Signed-off-by: Julien Thierry <jthierry@redhat.com>
> ---
>  tools/objtool/check.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 5968e6f08891..27e5380e0e0b 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -866,6 +866,13 @@ static int add_special_section_alts(struct objtool_file *file)
>  		}
>  
>  		if (special_alt->group) {
> +			if (!special_alt->orig_len) {
> +				WARN("empty alternative entry at %s+0x%lx",
> +				     orig_insn->sec->name,
> +				     orig_insn->offset);
> +				continue;
> +			}
> +

I think WARN_FUNC() can be used here instead.
Julien Thierry Jan. 23, 2020, 11:45 a.m. UTC | #2
On 1/21/20 4:30 PM, Josh Poimboeuf wrote:
> On Thu, Jan 09, 2020 at 04:02:07PM +0000, Julien Thierry wrote:
>> Atlernative section can contain entries for alternatives with no
>> instructions. Objtool will currently crash when handling such an entry.
>>
>> Just skip that entry, but still give a warning to discourage useless
>> entries.
>>
>> Signed-off-by: Julien Thierry <jthierry@redhat.com>
>> ---
>>   tools/objtool/check.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
>> index 5968e6f08891..27e5380e0e0b 100644
>> --- a/tools/objtool/check.c
>> +++ b/tools/objtool/check.c
>> @@ -866,6 +866,13 @@ static int add_special_section_alts(struct objtool_file *file)
>>   		}
>>   
>>   		if (special_alt->group) {
>> +			if (!special_alt->orig_len) {
>> +				WARN("empty alternative entry at %s+0x%lx",
>> +				     orig_insn->sec->name,
>> +				     orig_insn->offset);
>> +				continue;
>> +			}
>> +
> 
> I think WARN_FUNC() can be used here instead.
> 

I'll do that.

Thanks,
diff mbox series

Patch

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5968e6f08891..27e5380e0e0b 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -866,6 +866,13 @@  static int add_special_section_alts(struct objtool_file *file)
 		}
 
 		if (special_alt->group) {
+			if (!special_alt->orig_len) {
+				WARN("empty alternative entry at %s+0x%lx",
+				     orig_insn->sec->name,
+				     orig_insn->offset);
+				continue;
+			}
+
 			ret = handle_group_alt(file, special_alt, orig_insn,
 					       &new_insn);
 			if (ret)