ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Sheplyakov <asheplyakov@basealt.ru>
To: devel@lists.altlinux.org
Subject: Re: [devel] armh + libjpeg + c++ exceptions
Date: Tue, 23 Jun 2020 02:01:14 +0400
Message-ID: <ea01968d-89f2-6e04-a38b-17e67d22ec6e@basealt.ru> (raw)
In-Reply-To: <d6ad1a13-869e-a44b-2f48-caeb1ce8d6ca@basealt.ru>

On 6/22/20 7:46 PM, Alexey Sheplyakov wrote:
> On 6/22/20 7:27 PM, Alexey Sheplyakov wrote:
> 
>> Нельзя просто так взять и заставить C код бросать (C++) исключения.
>> Как минимум нужно
>>
>> 1) использовать для линковки g++ (не всегда
>> эквивалентно gcc -x c++ -lstdc++)
>> 2) все задействованные библиотеки собирать так, чтоб в них был 
>> GNU_EH_FRAME
>>
>> А у нас в armh его нет:
> 
> И не только у нас нет. Возможно, это ABI такой. Продолжаю курить 
> документацию.

arm использует другой механизм разматывания стека при обработке исключений.
Для того, чтобы его задействовать (в C приложениях и библиотеках),
нужно собирать с опцией -funwind-tables, (и само приложение,
и все библиотеки, которые могут оказаться в callchain исключения).

Проверить, собрана ли библиотека/приложение нужным образом, можно
командой

readelf -l path/to/libthat.so | grep EXIDX

Если молчит -- значит, библиотека исключения не поддерживает.

$ readelf -l  usr/lib/libjpeg.so.62

Elf file type is DYN (Shared object file)
Entry point 0x1a50
There are 6 program headers, starting at offset 52

Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
   LOAD           0x000000 0x00000000 0x00000000 0x28ca4 0x28ca4 R E 0x10000
   LOAD           0x028d00 0x00038d00 0x00038d00 0x00498 0x0049c RW  0x10000
   DYNAMIC        0x028f10 0x00038f10 0x00038f10 0x000f0 0x000f0 RW  0x4
   NOTE           0x0000f4 0x000000f4 0x000000f4 0x00024 0x00024 R   0x4
   GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
   GNU_RELRO      0x028d00 0x00038d00 0x00038d00 0x00300 0x00300 R   0x1

  Section to Segment mapping:
   Segment Sections...
    00     .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version 
.gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame
    01     .init_array .fini_array .data.rel.ro .dynamic .got .bss
    02     .dynamic
    03     .note.gnu.build-id
    04
    05     .init_array .fini_array .data.rel.ro .dynamic

т.е. наш libjpeg исключения не поддерживает. Что и подтверждает
пример из https://bugzilla.redhat.com/show_bug.cgi?id=101448

Что со всем этим делать?

1. Выяснить, каковы накладные расходы на поддержку исключений
2. Решить, приемлемы ли они
3. Если да, то собрать GCC так, чтобы -funwind-tables была по умолчанию
4. Если нет, то перестать бросать исключения их C программ,
    или включать -funwind-tables только там, где без исключений никак не 
обойтись.


  reply	other threads:[~2020-06-22 22:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 10:41 Vladislav Zavjalov
2020-06-22 14:39 ` Alexey Sheplyakov
2020-06-22 15:27   ` Alexey Sheplyakov
2020-06-22 15:46     ` Alexey Sheplyakov
2020-06-22 22:01       ` Alexey Sheplyakov [this message]
2020-06-23  9:49         ` Vladislav Zavjalov
2020-06-23 15:29           ` Alexey Sheplyakov
2020-06-23 16:49             ` Vladislav Zavjalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea01968d-89f2-6e04-a38b-17e67d22ec6e@basealt.ru \
    --to=asheplyakov@basealt.ru \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git