lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 13 Jan 2015 16:36:53 +0800
From:	Wang Nan <wangnan0@...wei.com>
To:	Jiri Olsa <jolsa@...hat.com>
CC:	<jolsa@...nel.org>, <namhyung@...nel.org>,
	<a.p.zijlstra@...llo.nl>, <paulus@...ba.org>, <mingo@...hat.com>,
	<acme@...nel.org>, <masami.hiramatsu.pt@...achi.com>,
	<jean.pihet@...aro.org>, <linux-kernel@...r.kernel.org>,
	<lizefan@...wei.com>
Subject: Re: [PATCH] perf: fix dwarf unwind using libunwind.

On 2015/1/13 15:10, Jiri Olsa wrote:
> On Tue, Jan 13, 2015 at 10:54:37AM +0800, Wang Nan wrote:
> 
> SNIP
> 
>>  
>> +static int elf_is_exec(int fd, const char *name)
>> +{
>> +	Elf *elf;
>> +	GElf_Ehdr ehdr;
>> +	int retval = 0;
>> +
>> +	elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
>> +	if (elf == NULL)
>> +		return 0;
>> +	if (gelf_getehdr(elf, &ehdr) == NULL)
>> +		goto out;
>> +
>> +	retval = (ehdr.e_type == ET_EXEC);
>> +
>> +out:
>> +	elf_end(elf);
>> +	pr_debug("unwind: elf_is_exec(%s): %d\n", name, retval);
>> +	return retval;
>> +
>> +}
> 
> yuou need to add stub for 'NO_LIBUNWIND_DEBUG_FRAME=1', otherwise:
> 
>   CC       util/dwarf-aux.o
>   CC       util/unwind-libunwind.o
> util/unwind-libunwind.c:188:12: error: ‘elf_is_exec’ defined but not used [-Werror=unused-function]
>  static int elf_is_exec(int fd, const char *name)
>             ^
> cc1: all warnings being treated as errors
> make[1]: *** [util/unwind-libunwind.o] Error 1
> make[1]: *** Waiting for unfinished jobs....
> make: *** [all] Error 2
> 
> jirka
> 

Thanks. I haven't test NO_LIBUNWIND_DEBUG_FRAME=1 case.

I found that it is possible to utilize map->dso->adjust_symbols for this propose so
we don't need to introduce another function to check ehdr.e_type. However
map->dso->adjust_symbols checks not only ET_EXEC but also ET_REL. What do you think?

I'd like to check it and post another patch.

>> +
>>  struct table_entry {
>>  	u32 start_ip_offset;
>>  	u32 fde_offset;
>> @@ -322,8 +343,12 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
>>  #ifndef NO_LIBUNWIND_DEBUG_FRAME
>>  	/* Check the .debug_frame section for unwinding info */
>>  	if (!read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) {
>> +		int fd = dso__data_fd(map->dso, ui->machine);
>> +		int is_exec = elf_is_exec(fd, map->dso->name);
>> +		unw_word_t base = is_exec ? 0 : map->start;
>> +
>>  		memset(&di, 0, sizeof(di));
>> -		if (dwarf_find_debug_frame(0, &di, ip, 0, map->dso->name,
>> +		if (dwarf_find_debug_frame(0, &di, ip, base, map->dso->name,
>>  					   map->start, map->end))
>>  			return dwarf_search_unwind_table(as, ip, &di, pi,
>>  							 need_unwind_info, arg);
>> -- 
>> 1.8.4
>>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ